[DEV] set back display of the video ==> must do it better
This commit is contained in:
parent
2c85f1992b
commit
ec9f88fccb
@ -619,6 +619,7 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#define APPL_BUFFER_SIZE_FOR_FFMPEG (256*1024)
|
||||
|
||||
void appl::MediaDecoder::init() {
|
||||
if ( m_isInit == true
|
||||
@ -642,8 +643,8 @@ void appl::MediaDecoder::init() {
|
||||
APPL_ERROR("Could not create Format context");
|
||||
return;
|
||||
}
|
||||
uint8_t* ploooooo = (uint8_t*)av_malloc(1024*1024);
|
||||
m_IOContext = avio_alloc_context(ploooooo, 1024*1024, 0 /* can not write */, this, g_readFunc, g_writeFunc, g_seekFunc);
|
||||
uint8_t* ploooooo = (uint8_t*)av_malloc(APPL_BUFFER_SIZE_FOR_FFMPEG);
|
||||
m_IOContext = avio_alloc_context(ploooooo, APPL_BUFFER_SIZE_FOR_FFMPEG, 0 /* can not write */, this, g_readFunc, g_writeFunc, g_seekFunc);
|
||||
if (m_IOContext == nullptr) {
|
||||
APPL_ERROR("Could not create IO stream");
|
||||
return;
|
||||
@ -769,7 +770,7 @@ bool appl::MediaDecoder::onThreadCall() {
|
||||
applySeek(tmpSeek);
|
||||
}
|
||||
// Need to wait at lease 1MB
|
||||
if (m_remote->sizeReadable() < 1024*1024) {
|
||||
if (m_remote->sizeReadable() < APPL_BUFFER_SIZE_FOR_FFMPEG) {
|
||||
// take some time to sleep the decoding ...
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(60/100));
|
||||
return false;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <ejson/ejson.hpp>
|
||||
#include <appl/widget/Connection.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <appl/widget/Player.hpp>
|
||||
|
||||
|
||||
static std::string g_baseDBName = "USERDATA:config.json";
|
||||
@ -82,10 +83,6 @@ void appl::Windows::init() {
|
||||
m_listViewer = ememory::dynamicPointerCast<appl::widget::ListViewer>(m_composer->getSubObjectNamed("ws-name-list-viewer"));
|
||||
m_listViewer->signalSelect.connect(sharedFromThis(), &appl::Windows::onCallbackSelectMedia);
|
||||
|
||||
subBind(ewol::widget::Button, "bt-previous", signalPressed, sharedFromThis(), &appl::Windows::onCallbackPrevious);
|
||||
subBind(ewol::widget::Button, "bt-play", signalValue, sharedFromThis(), &appl::Windows::onCallbackPlay);
|
||||
subBind(ewol::widget::Button, "bt-next", signalPressed, sharedFromThis(), &appl::Windows::onCallbackNext);
|
||||
subBind(ewol::widget::Button, "bt-back", signalPressed, sharedFromThis(), &appl::Windows::onCallbackBack);
|
||||
subBind(appl::widget::VideoDisplay, "displayer", signalFps, sharedFromThis(), &appl::Windows::onCallbackFPS);
|
||||
subBind(appl::widget::VideoDisplay, "displayer", signalPosition, sharedFromThis(), &appl::Windows::onCallbackPosition);
|
||||
subBind(ewol::widget::Slider, "progress-bar", signalChange, sharedFromThis(), &appl::Windows::onCallbackSeekRequest);
|
||||
@ -236,17 +233,8 @@ void appl::Windows::onCallbackBack() {
|
||||
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackPlay(const bool& _isPressed) {
|
||||
ememory::SharedPtr<appl::widget::VideoDisplay> tmpDisp = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("displayer"));
|
||||
if (tmpDisp == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (_isPressed == true) {
|
||||
tmpDisp->play();
|
||||
} else {
|
||||
tmpDisp->pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void appl::Windows::onCallbackNext() {
|
||||
m_id++;
|
||||
@ -333,17 +321,9 @@ void appl::Windows::onCallbackSelectSourses() {
|
||||
|
||||
void appl::Windows::onCallbackSelectMedia(const uint32_t& _value) {
|
||||
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-player");
|
||||
ememory::SharedPtr<appl::widget::VideoDisplay> tmpDisp = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("displayer"));
|
||||
if (tmpDisp != nullptr) {
|
||||
// stop previous (if needed)
|
||||
tmpDisp->stop();
|
||||
// Set new file:
|
||||
tmpDisp->setZeusMedia(m_clientProp, _value);
|
||||
tmpDisp->play();
|
||||
echrono::Duration time = tmpDisp->getDuration();
|
||||
APPL_DEBUG("duration = " << time << " " << etk::to_string(time.toSeconds()));
|
||||
propertySetOnWidgetNamed("progress-bar", "value", "0");
|
||||
propertySetOnWidgetNamed("progress-bar", "max", etk::to_string(time.toSeconds()));
|
||||
ememory::SharedPtr<appl::widget::Player> tmpPlayer = ememory::dynamicPointerCast<appl::widget::Player>(getSubObjectNamed("ws-name-player"));
|
||||
if (tmpPlayer != nullptr) {
|
||||
tmpPlayer->playStream(m_clientProp, _value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,10 @@
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/tools/message.hpp>
|
||||
|
||||
appl::widget::Player::Player() {
|
||||
appl::widget::Player::Player() :
|
||||
signalFinished(this, "finish", "The playing of the stream is finished"),
|
||||
signalNext(this, "next", "User request the next stream"),
|
||||
signalPrevious(this, "previous", "User request the previous stream") {
|
||||
addObjectType("appl::widget::Player");
|
||||
}
|
||||
|
||||
@ -35,6 +38,8 @@ void appl::widget::Player::init() {
|
||||
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-previous", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonPrevious);
|
||||
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-play", signalValue, sharedFromThis(), &appl::widget::Player::onCallbackButtonPlay);
|
||||
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-next", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonNext);
|
||||
|
||||
m_display = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display"));
|
||||
propertyCanFocus.set(true);
|
||||
markToRedraw();
|
||||
}
|
||||
@ -49,16 +54,49 @@ appl::widget::Player::~Player() {
|
||||
|
||||
}
|
||||
|
||||
void appl::widget::Player::playStream(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId) {
|
||||
if (m_display == nullptr) {
|
||||
return;
|
||||
}
|
||||
// stop previous (if needed)
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false");
|
||||
m_display->stop();
|
||||
// Set new file:
|
||||
m_display->setZeusMedia(_property, _mediaId);
|
||||
m_display->play();
|
||||
//echrono::Duration time = tmpDisp->getDuration();
|
||||
//APPL_DEBUG("duration = " << time << " " << etk::to_string(time.toSeconds()));
|
||||
//propertySetOnWidgetNamed("progress-bar", "value", "0");
|
||||
//propertySetOnWidgetNamed("progress-bar", "max", etk::to_string(time.toSeconds()));
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "true");
|
||||
}
|
||||
|
||||
void appl::widget::Player::suspend() {
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false");
|
||||
if (m_display == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_display->pause();
|
||||
}
|
||||
|
||||
|
||||
void appl::widget::Player::onCallbackButtonPrevious() {
|
||||
|
||||
signalPrevious.emit();
|
||||
}
|
||||
|
||||
void appl::widget::Player::onCallbackButtonPlay(const bool& _value) {
|
||||
|
||||
if (m_display == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (_value == true) {
|
||||
m_display->play();
|
||||
} else {
|
||||
m_display->pause();
|
||||
}
|
||||
}
|
||||
|
||||
void appl::widget::Player::onCallbackButtonNext() {
|
||||
|
||||
signalNext.emit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <appl/widget/VideoPlayer.hpp>
|
||||
#include <appl/ClientProperty.hpp>
|
||||
|
||||
namespace appl {
|
||||
@ -20,6 +21,9 @@ namespace appl {
|
||||
public: // properties
|
||||
|
||||
public: // signals
|
||||
esignal::Signal<> signalFinished; //!< the play is finished
|
||||
esignal::Signal<> signalNext; //!< Next file is requested
|
||||
esignal::Signal<> signalPrevious; //!< Previous file is requested
|
||||
|
||||
protected:
|
||||
Player();
|
||||
@ -27,6 +31,11 @@ namespace appl {
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Player, "Player");
|
||||
virtual ~Player();
|
||||
protected:
|
||||
ememory::SharedPtr<appl::widget::VideoDisplay> m_display; //!< Display widget
|
||||
public:
|
||||
void playStream(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId);
|
||||
void suspend();
|
||||
public:
|
||||
void onGetFocus() override;
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user