diff --git a/tools/player-video/appl/ClientProperty.cpp b/tools/player-video/appl/ClientProperty.cpp index 4077b75..d1c36e6 100644 --- a/tools/player-video/appl/ClientProperty.cpp +++ b/tools/player-video/appl/ClientProperty.cpp @@ -49,6 +49,12 @@ void appl::ClientProperty::fromJson(ejson::Object _obj) { } void appl::ClientProperty::connect() { + if (connection.isAlive() == true) { + connection.pingIsAlive(); + if (connection.isAlive() == true) { + return; + } + } // Generate IP and Port in the client interface if (address == "") { connection.propertyIp.set("127.0.0.1"); diff --git a/tools/player-video/appl/Main.cpp b/tools/player-video/appl/Main.cpp index 9bd5458..cb03ce9 100644 --- a/tools/player-video/appl/Main.cpp +++ b/tools/player-video/appl/Main.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include namespace appl { @@ -70,6 +71,7 @@ namespace appl { // set application widget: appl::widget::VideoDisplay::createManagerWidget(_context.getWidgetManager()); appl::widget::ListViewer::createManagerWidget(_context.getWidgetManager()); + appl::widget::Player::createManagerWidget(_context.getWidgetManager()); // Create the windows ememory::SharedPtr basicWindows = appl::Windows::create(); // configure the ewol context to use the new windows diff --git a/tools/player-video/appl/MediaDecoder.cpp b/tools/player-video/appl/MediaDecoder.cpp index e560b53..35ef925 100644 --- a/tools/player-video/appl/MediaDecoder.cpp +++ b/tools/player-video/appl/MediaDecoder.cpp @@ -22,7 +22,6 @@ #define BUFFER_SIZE_GET_SLOT (1024*512) - static int g_readFunc(void* _opaque, uint8_t* _buf, int _bufSize) { if (_opaque == nullptr) { return 0; @@ -354,38 +353,33 @@ void appl::MediaDecoder::init(ememory::SharedPtr _property, uint APPL_ERROR("Request play of not connected handle ==> 'not alive'"); return; } - - APPL_ERROR("AAAAAAAAAAAA"); zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video"); // remove all media (for test) if (remoteServiceVideo.exist() == false) { APPL_ERROR("Video service is ==> 'not alive'"); return; } - APPL_ERROR("AAAA 222"); m_remote = ememory::makeShared(); m_remote->m_bufferReadPosition = 0; m_remote->m_property = _property; m_remote->m_mediaId = _mediaId; - APPL_ERROR("AAAA 333"); remoteServiceVideo.mediaGet(_mediaId).andThen( [=](zeus::Future _fut) mutable { - APPL_ERROR("Receive ProxyFile"); + APPL_INFO("Receive ProxyFile"); m_remote->m_fileHandle = _fut.get(); m_remote->m_fileHandle.getSize().andThen( [=](zeus::Future _fut) mutable { - APPL_ERROR("Receive FileSize to index property"); + APPL_INFO("Receive FileSize to index property"); m_remote->m_buffer.resize(_fut.get(), 0); m_remote->checkIfWeNeedMoreDataFromNetwork(); return true; }); return true; }); - init(); } int appl::MediaDecoder::readFunc(uint8_t* _buf, int _bufSize) { - APPL_ERROR("call read ... " << m_remote->m_bufferReadPosition << " size=" << _bufSize); + APPL_INFO("call read ... " << m_remote->m_bufferReadPosition << " size=" << _bufSize); // check if enought data: int64_t readableSize = m_remote->sizeReadable(); if (_bufSize > readableSize) { @@ -400,6 +394,7 @@ int appl::MediaDecoder::readFunc(uint8_t* _buf, int _bufSize) { memcpy(_buf, &m_remote->m_buffer[m_remote->m_bufferReadPosition], _bufSize); m_remote->m_bufferReadPosition += _bufSize; } + m_remote->startStream(); m_remote->checkIfWeNeedMoreDataFromNetwork(); return _bufSize; } @@ -522,9 +517,17 @@ bool appl::StreamBuffering::addDataCallback(zeus::Future _fut, int64_ appl::StreamBuffering::StreamBuffering() { m_callInProgress = false; + m_stopRequested = false; m_mediaId = 0; m_bufferReadPosition = 0; } +void appl::StreamBuffering::stopStream() { + m_stopRequested = true; +} +void appl::StreamBuffering::startStream() { + m_stopRequested = false; +} + void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { std::unique_lock lock(m_mutex); @@ -533,18 +536,21 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { if (m_callInProgress == true) { return; } + if (m_stopRequested == true) { + return; + } int32_t preDownloadBufferSlot = BUFFER_SIZE_GET_SLOT*3; // When file is < 200Mo ==> just download all... if (m_buffer.size() < 300*1024*1024) { preDownloadBufferSlot = m_buffer.size()+10; } - APPL_INFO("Request DATA ..."); + APPL_VERBOSE("Request DATA ..."); auto it = m_bufferFillSection.begin(); if (it == m_bufferFillSection.end()) { // no data in the buffer... //Get some // start with loading of 1 Mo - APPL_INFO("Request DATA : " << 0 << " size=" << BUFFER_SIZE_GET_SLOT); + APPL_VERBOSE("Request DATA : " << 0 << " size=" << BUFFER_SIZE_GET_SLOT); auto futData = m_fileHandle.getPart(0, BUFFER_SIZE_GET_SLOT); auto localShared = ememory::dynamicPointerCast(sharedFromThis()); futData.andThen([=](zeus::Future _fut) mutable { @@ -554,10 +560,9 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { return; } while (it != m_bufferFillSection.end()) { - APPL_INFO("Check : " << it->first << " -> " << it->second << " read-pos=" << m_bufferReadPosition); + APPL_VERBOSE("Check : " << it->first << " -> " << it->second << " read-pos=" << m_bufferReadPosition); if ( m_bufferReadPosition >= it->first && m_bufferReadPosition < it->second) { - APPL_INFO("Request DATA AAAA "); find = true; // part already download... ==> check if we need more data after end position if (it->second == m_buffer.size()) { @@ -575,7 +580,7 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { && it->second + sizeRequest >= it2->first) { sizeRequest = it2->first - it->second; } - APPL_INFO("Request DATA : " << it->second << " size=" << sizeRequest); + APPL_VERBOSE("Request DATA : " << it->second << " size=" << sizeRequest); auto futData = m_fileHandle.getPart(it->second, it->second + sizeRequest); auto localShared = ememory::dynamicPointerCast(sharedFromThis()); futData.andThen([=](zeus::Future _fut) mutable { @@ -586,12 +591,11 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { // nothing more to do ... return; } else if (m_bufferReadPosition < it->first) { - APPL_INFO("Request DATA KKKKK "); int32_t sizeRequest = BUFFER_SIZE_GET_SLOT; if (m_bufferReadPosition + sizeRequest >= it->first) { sizeRequest = it->first - m_bufferReadPosition; } - APPL_INFO("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest); + APPL_VERBOSE("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest); auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition+sizeRequest); auto localShared = ememory::dynamicPointerCast(sharedFromThis()); futData.andThen([=](zeus::Future _fut) mutable { @@ -603,8 +607,7 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { } ++it; } - APPL_INFO("Request DATA RRRRR "); - APPL_INFO("Request DATA : " << m_bufferReadPosition << " size=" << BUFFER_SIZE_GET_SLOT); + APPL_VERBOSE("Request DATA : " << m_bufferReadPosition << " size=" << BUFFER_SIZE_GET_SLOT); auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition + BUFFER_SIZE_GET_SLOT); auto localShared = ememory::dynamicPointerCast(sharedFromThis()); futData.andThen([=](zeus::Future _fut) mutable { @@ -618,13 +621,13 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { } void appl::MediaDecoder::init() { - //APPL_ERROR("AAAAAAAAAAAA " << m_isInit << " " << m_remote->sizeReadable()); if ( m_isInit == true || m_remote == nullptr || m_remote->sizeReadable() < 1024*1024) {// Need to wait at lease 1MB return; } + m_remote->startStream(); m_updateVideoTimeStampAfterSeek = false; //m_sourceFilename = _filename; ethread::setName("ffmpegThread"); @@ -635,13 +638,12 @@ void appl::MediaDecoder::init() { return; } #else - if (!(m_formatContext = avformat_alloc_context())) { APPL_ERROR("Could not create Format context"); return; } - m_bufferFFMPEG.resize(1024*1024); // 1Mo buffer is good enought - m_IOContext = avio_alloc_context(&m_bufferFFMPEG[0], m_bufferFFMPEG.size(), 0 /* can not write */, this, g_readFunc, g_writeFunc, g_seekFunc); + 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); if (m_IOContext == nullptr) { APPL_ERROR("Could not create IO stream"); return; @@ -805,15 +807,37 @@ void appl::MediaDecoder::uninit() { return; } APPL_PRINT("Demuxing & Decoding succeeded..."); + flushMessage(); avcodec_close(m_videoDecoderContext); avcodec_close(m_audioDecoderContext); + m_formatContext->pb = nullptr; avformat_close_input(&m_formatContext); av_frame_free(&m_frame); + av_free(m_IOContext); + m_IOContext = nullptr; + m_audioPool.clear(); + m_videoPool.clear(); + m_updateVideoTimeStampAfterSeek = false; + m_videoStream = nullptr; + m_audioStream = nullptr; + m_sourceFilename = ""; + m_videoStream_idx = 0; + m_audioStream_idx = 0; + m_videoFrameCount = 0; + m_audioFrameCount = 0; + // output format convertion: + m_convertContext = nullptr; + m_remote.reset(); m_isInit = false; + APPL_PRINT("Demuxing & Decoding succeeded... (DONE)"); } void appl::MediaDecoder::stop() { m_stopRequested = true; + if (m_remote != nullptr) { + m_remote->stopStream(); + } + gale::Thread::stop(); } void appl::MediaDecoder::flushMessage() { diff --git a/tools/player-video/appl/MediaDecoder.hpp b/tools/player-video/appl/MediaDecoder.hpp index d39ac21..f424abe 100644 --- a/tools/player-video/appl/MediaDecoder.hpp +++ b/tools/player-video/appl/MediaDecoder.hpp @@ -66,6 +66,7 @@ namespace appl { int32_t m_bufferReadPosition; //!< Current position that is read std::vector> m_bufferFillSection; //!< List of position that contain data bool m_callInProgress; + bool m_stopRequested; public: bool addDataCallback(zeus::Future _fut, int64_t _positionRequest); void checkIfWeNeedMoreDataFromNetwork(); @@ -76,6 +77,8 @@ namespace appl { return m_bufferFillSection; } int32_t sizeReadable(); + void stopStream(); + void startStream(); }; class MediaDecoder : public gale::Thread { bool m_stopRequested; @@ -102,7 +105,6 @@ namespace appl { int32_t audioGetEmptySlot(); private: AVIOContext* m_IOContext; - std::vector m_bufferFFMPEG; AVFormatContext* m_formatContext; AVCodecContext* m_videoDecoderContext; AVCodecContext* m_audioDecoderContext; diff --git a/tools/player-video/appl/Windows.cpp b/tools/player-video/appl/Windows.cpp index 002afb8..cbb2351 100644 --- a/tools/player-video/appl/Windows.cpp +++ b/tools/player-video/appl/Windows.cpp @@ -36,8 +36,6 @@ void appl::Windows::store_db() { if (m_clientProp != nullptr) { database.add("access", m_clientProp->toJson()); } - //database.add("login", ejson::String(m_login)); - //database.add("pass", ejson::String(m_password)); bool retGenerate = database.storeSafe(g_baseDBName); APPL_ERROR("Store database [STOP] : " << (g_baseDBName) << " ret = " << retGenerate); } @@ -59,8 +57,6 @@ void appl::Windows::load_db() { if (m_clientProp != nullptr) { m_clientProp->fromJson(database["access"].toObject()); } - //m_login = database["login"].toString().get(); - //m_password = database["pass"].toString().get(); } @@ -92,11 +88,6 @@ void appl::Windows::init() { subBind(appl::widget::VideoDisplay, "displayer", signalPosition, sharedFromThis(), &appl::Windows::onCallbackPosition); subBind(ewol::widget::Slider, "progress-bar", signalChange, sharedFromThis(), &appl::Windows::onCallbackSeekRequest); - /* - subBind(ewol::widget::Entry, "connect-login", signalModify, sharedFromThis(), &appl::Windows::onCallbackConnectLogin); - subBind(ewol::widget::Entry, "connect-password", signalModify, sharedFromThis(), &appl::Windows::onCallbackConnectPassword); - subBind(ewol::widget::Button, "connect-bt", signalPressed, sharedFromThis(), &appl::Windows::onCallbackConnectConnect); - subBind(ewol::widget::Button, "bt-film-picture", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectFilms); subBind(ewol::widget::Button, "bt-film-draw", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectAnnimation); @@ -105,10 +96,9 @@ void appl::Windows::init() { subBind(ewol::widget::Button, "bt-theater", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectTeather); subBind(ewol::widget::Button, "bt-one-man-show", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectOneManShow); subBind(ewol::widget::Button, "bt-courses", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectSourses); - */ - propertySetOnWidgetNamed("connect-login", "value", m_login); - propertySetOnWidgetNamed("connect-password", "value", m_password); + subBind(ewol::widget::Button, "access-fast-home", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectHome); + subBind(ewol::widget::Button, "access-fast-group", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectGroup); // Direct display list: ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); @@ -156,6 +146,45 @@ void appl::Windows::onCallbackMenuEvent(const std::string& _value) { popUpWidgetPush(tmpWidget); } else if (_value == "menu:exit") { gale::getContext().stop(); + } else if (_value == "menu:home") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements(""); + } else if (_value == "menu:group") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-group"); + } else if (_value == "menu:tv") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-tv"); + + } else if (_value == "menu:films") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("film"); + } else if (_value == "menu:animation-films") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("annimation"); + } else if (_value == "menu:tv-show") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("tv-show"); + } else if (_value == "menu:animation-tv-show") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("tv-annimation"); + } else if (_value == "menu:teather") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("teather"); + } else if (_value == "menu:one-man-show") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("one-man"); + } else if (_value == "menu:courses") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements("courses"); + + + } else if (_value == "menu:TV-child") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements(""); + // TODO: ... + } else if (_value == "menu:TV-adult") { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + m_listViewer->searchElements(""); + // TODO: ... } else if (_value == "menu:reload-shader") { ewol::getContext().getResourcesManager().reLoadResources(); ewol::getContext().forceRedrawAll(); @@ -272,65 +301,6 @@ void appl::Windows::onCallbackSeekRequest(const float& _value) { } } - -void appl::Windows::onCallbackConnectLogin(const std::string& _value) { - m_login = _value; - store_db(); -} - -void appl::Windows::onCallbackConnectPassword(const std::string& _value) { - m_password = _value; - store_db(); -} - -void appl::Windows::onCallbackConnectConnect() { - APPL_INFO("Connect with : '" << m_login << "' ... '" << m_password << "'"); - - m_clientProp = ememory::makeShared(); - if (m_clientProp == nullptr) { - APPL_ERROR("Can not create property"); - return; - } - m_clientProp->address = "127.0.0.1"; - m_clientProp->port = 1983; - - // check connection is correct: - zeus::Client client1; - // separate loggin and IP adress ... - std::string login; - std::vector listElem = etk::split(m_login, '~'); - login = listElem[0]; - if (listElem.size() == 1) { - // connnect on local host ... nothing to do - } else { - std::vector listElem2 = etk::split(listElem[0], ':'); - client1.propertyIp.set(listElem2[0]); - m_clientProp->address = listElem2[0]; - if (listElem2.size() >= 1) { - client1.propertyPort.set(etk::string_to_uint32_t(listElem2[1])); - m_clientProp->port = etk::string_to_uint32_t(listElem2[1]); - } - } - m_clientProp->fromUser = login; - m_clientProp->toUser = login; - m_clientProp->pass = m_password; - m_clientProp->connect(); - - if (m_clientProp->connection.isAlive() == false) { - APPL_ERROR(" ==> NOT Authentify to '" << login << "'"); - ewol::tools::message::displayError("Can not connect the server with
'" + login + "'"); - } else { - APPL_INFO(" ==> Authentify with '" << login << "'"); - ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list"); - // set the client property interface: - if (m_listViewer == nullptr) { - APPL_ERROR("Nullptr in the viewer ..."); - } else { - m_listViewer->setClientProperty(m_clientProp); - } - } -} - void appl::Windows::onCallbackSelectFilms() { ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); m_listViewer->searchElements("film"); diff --git a/tools/player-video/appl/Windows.hpp b/tools/player-video/appl/Windows.hpp index 4f3ebf4..f40d195 100644 --- a/tools/player-video/appl/Windows.hpp +++ b/tools/player-video/appl/Windows.hpp @@ -41,11 +41,6 @@ namespace appl { void onCallbackShortCut(const std::string& _value); void onCallbackMenuEvent(const std::string& _value); protected: - std::string m_login; - std::string m_password; - void onCallbackConnectLogin(const std::string& _value); - void onCallbackConnectPassword(const std::string& _value); - void onCallbackConnectConnect(); void load_db(); void store_db(); void onCallbackSelectFilms(); @@ -56,6 +51,12 @@ namespace appl { void onCallbackSelectOneManShow(); void onCallbackSelectSourses(); void onCallbackSelectMedia(const uint32_t& _value); + void onCallbackSelectGroup() { + onCallbackMenuEvent("menu:group"); + } + void onCallbackSelectHome() { + onCallbackMenuEvent("menu:home"); + } }; } diff --git a/tools/player-video/appl/widget/ListViewer.cpp b/tools/player-video/appl/widget/ListViewer.cpp index 53a07e3..a025707 100644 --- a/tools/player-video/appl/widget/ListViewer.cpp +++ b/tools/player-video/appl/widget/ListViewer.cpp @@ -29,7 +29,7 @@ appl::widget::ListViewer::ListViewer() : signalSelect(this, "select", "Select a media to view") { addObjectType("appl::widget::ListViewer"); propertyCanFocus.setDirectCheck(true); - // Limit event at 1: + setLimitScrolling(0.2); setMouseLimit(1); } @@ -46,6 +46,7 @@ appl::widget::ListViewer::~ListViewer() { void appl::widget::ListViewer::searchElements(std::string _filter) { m_listElement.clear(); + m_listDisplay.clear(); if (m_clientProp == nullptr) { APPL_ERROR("No client Availlable ..."); return; @@ -68,6 +69,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) { _filter = "*"; } + m_clientProp->connect(); if (m_clientProp->connection.isAlive() == false) { APPL_ERROR("Conection is not alive anymore ..."); return; @@ -148,6 +150,26 @@ void appl::widget::ListViewer::searchElements(std::string _filter) { tmpWidget->markToRedraw(); return true; }); + remoteServiceVideo.mediaMetadataGetKey(it, "production-methode") + .andThen([=](zeus::Future _fut) mutable { + APPL_INFO(" [" << elem->m_id << "] get production-methode: " << _fut.get()); + { + std::unique_lock lock(elem->m_mutex); + elem->m_productMethode = _fut.get(); + } + tmpWidget->markToRedraw(); + return true; + }); + remoteServiceVideo.mediaMetadataGetKey(it, "type") + .andThen([=](zeus::Future _fut) mutable { + APPL_INFO(" [" << elem->m_id << "] get type: " << _fut.get()); + { + std::unique_lock lock(elem->m_mutex); + elem->m_type = _fut.get(); + } + tmpWidget->markToRedraw(); + return true; + }); remoteServiceVideo.mediaMineTypeGet(it) .andThen([=](zeus::Future _fut) mutable { APPL_INFO(" [" << elem->m_id << "] get mine-type: " << _fut.get()); @@ -165,22 +187,6 @@ void appl::widget::ListViewer::searchElements(std::string _filter) { tmpWidget->markToRedraw(); return true; }); - /* - elem->m_title = remoteServiceVideo.mediaMetadataGetKey(it, "title").wait().get(); - elem->m_serie = remoteServiceVideo.mediaMetadataGetKey(it, "series-name").wait().get(); - elem->m_saison = remoteServiceVideo.mediaMetadataGetKey(it, "saison").wait().get(); - elem->m_episode = remoteServiceVideo.mediaMetadataGetKey(it, "episode").wait().get(); - elem->m_description = remoteServiceVideo.mediaMetadataGetKey(it, "description").wait().get(); - elem->m_mineType = remoteServiceVideo.mediaMineTypeGet(it).wait().get(); - if (etk::start_with(elem->m_mineType, "video") == true) { - // TODO : Optimise this ... - elem->m_thumb = egami::load("DATA:Video.svg", ivec2(128,128)); - } else if (etk::start_with(elem->m_mineType, "audio") == true) { - // TODO : Optimise this ... - elem->m_thumb = egami::load("DATA:MusicNote.svg", ivec2(128,128)); - } - elem->m_metadataUpdated = true; - */ elem->m_metadataUpdated = true; //elem->m_thumb = remoteServiceVideo.mediaThumbGet(it, 128).wait().get(); m_listElement.push_back(elem); @@ -286,7 +292,7 @@ void appl::widget::ListViewer::onRegenerateDisplay() { if (iii < m_listElement.size()) { elem->m_property = m_listElement[iii]; } - switch(iii) { + switch(iii%6) { case 0: elem->m_bgColor = etk::color::red; break; @@ -315,13 +321,18 @@ void appl::widget::ListViewer::onRegenerateDisplay() { } // Now we request display of the elements: vec2 elementSize = vec2(m_size.x(), int32_t(realPixelSize.y())); - vec2 startPos = vec2(0, m_size.y()) - vec2(0, elementSize.y()); + vec2 startPos = vec2(-m_originScrooled.x(), m_size.y()) - vec2(0, elementSize.y()-m_originScrooled.y()); for (auto &it : m_listDisplay) { if (it == nullptr) { startPos -= vec2(0, elementSize.y()); continue; } - it->generateDisplay(startPos, elementSize); + if ( startPos.y() - elementSize.y() <= m_size.y() + && startPos.y() + elementSize.y() >= 0) { + it->generateDisplay(startPos, elementSize); + } else { + it->clear(); + } startPos -= vec2(0, elementSize.y()); } m_maxSize.setX(m_size.x()); @@ -392,6 +403,13 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { textToDisplay += "Episode: " + m_property->m_episode + " "; newLine = true; } + if (m_property->m_type != "") { + textToDisplay += " type: " + m_property->m_type + " "; + if (m_property->m_productMethode != "") { + textToDisplay += " / " + m_property->m_productMethode + " "; + } + newLine = true; + } if (newLine == true) { textToDisplay += "
"; } @@ -415,7 +433,10 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { - APPL_VERBOSE("Event on BT : " << _event); + if (ewol::widget::WidgetScrolled::onEventInput(_event) == true) { + return true; + } + APPL_VERBOSE("Event on BT : " << _event << " size=" << m_size << " maxSize=" << m_maxSize); vec2 relativePos = relativePosition(_event.getPos()); int32_t findId = -1; for (size_t iii=0; iiim_idCurentElement); + APPL_DEBUG("Select element : " << findId << " " << m_listDisplay[findId]->m_idCurentElement); ememory::SharedPtr prop = m_listDisplay[findId]->m_property; if (prop != nullptr) { std::string fullTitle; @@ -450,7 +471,7 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { fullTitle += "e" + prop->m_episode + "-"; } fullTitle += prop->m_title; - APPL_WARNING("info element : " << prop->m_id << " title: " << fullTitle); + APPL_DEBUG("info element : " << prop->m_id << " title: " << fullTitle); signalSelect.emit(prop->m_id); } return true; diff --git a/tools/player-video/appl/widget/ListViewer.hpp b/tools/player-video/appl/widget/ListViewer.hpp index 79197ef..d6f8341 100644 --- a/tools/player-video/appl/widget/ListViewer.hpp +++ b/tools/player-video/appl/widget/ListViewer.hpp @@ -29,6 +29,8 @@ namespace appl { std::string m_episode; //!< Id of the Episode or empty std::string m_saison; //!< id of the saison or empty std::string m_mineType; //!< mine type: video/audio/image/... + std::string m_type; //!< type of the element + std::string m_productMethode; //!< Methode of production // TODO: float m_globalNote; //!< note over [0,0..1,0] // TODO: int32_t m_countPersonalView; //!< number of view this media // TODO: int64_t m_globalPersonalView; //!< number of time this media has been viewed @@ -51,6 +53,11 @@ namespace appl { m_text.draw(); } void generateDisplay(vec2 _startPos, vec2 _size); + void clear() { + m_image.clear(); + m_text.clear(); + m_draw.clear(); + } }; namespace widget { diff --git a/tools/player-video/appl/widget/Player.cpp b/tools/player-video/appl/widget/Player.cpp new file mode 100644 index 0000000..6f86f41 --- /dev/null +++ b/tools/player-video/appl/widget/Player.cpp @@ -0,0 +1,66 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include +#include + +appl::widget::Player::Player() { + addObjectType("appl::widget::Player"); +} + +void appl::widget::Player::init() { + ewol::widget::Composer::init(); + if (loadFromFile("DATA:gui-player.xml", getId()) == false) { + APPL_ERROR("Can not load Player GUI from file ..."); + return; + } + 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); + propertyCanFocus.set(true); + markToRedraw(); +} + + +void appl::widget::Player::onGetFocus() { + // transfert focus on a specific widget... + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "focus", "true"); +} + +appl::widget::Player::~Player() { + +} + +void appl::widget::Player::onCallbackButtonPrevious() { + +} + +void appl::widget::Player::onCallbackButtonPlay(const bool& _value) { + +} + +void appl::widget::Player::onCallbackButtonNext() { + +} + + diff --git a/tools/player-video/appl/widget/Player.hpp b/tools/player-video/appl/widget/Player.hpp new file mode 100644 index 0000000..2df189c --- /dev/null +++ b/tools/player-video/appl/widget/Player.hpp @@ -0,0 +1,39 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +#pragma once + +#include +#include +#include +#include +#include + +namespace appl { + namespace widget { + class Player; + using PlayerShared = ememory::SharedPtr; + using PlayerWeak = ememory::WeakPtr; + class Player : public ewol::widget::Composer { + public: // properties + + public: // signals + + protected: + Player(); + void init() override; + public: + DECLARE_WIDGET_FACTORY(Player, "Player"); + virtual ~Player(); + public: + void onGetFocus() override; + private: + // callback functions: + void onCallbackButtonPrevious(); + void onCallbackButtonNext(); + void onCallbackButtonPlay(const bool& _value); + }; + }; +}; diff --git a/tools/player-video/appl/widget/VideoPlayer.cpp b/tools/player-video/appl/widget/VideoPlayer.cpp index 2e65417..0f643a0 100644 --- a/tools/player-video/appl/widget/VideoPlayer.cpp +++ b/tools/player-video/appl/widget/VideoPlayer.cpp @@ -53,7 +53,6 @@ void appl::widget::VideoDisplay::init() { } // Create the River manager for tha application or part of the application. m_audioManager = audio::river::Manager::create("river_sample_read"); - //! [audio_river_sample_create_write_interface] } appl::widget::VideoDisplay::~VideoDisplay() { @@ -93,10 +92,16 @@ void appl::widget::VideoDisplay::setFile(const std::string& _filename) { void appl::widget::VideoDisplay::setZeusMedia(ememory::SharedPtr _property, uint32_t _mediaId) { // Stop playing in all case... stop(); + if (m_decoder != nullptr) { + m_decoder->uninit(); + } // Clear the old interface m_decoder.reset(); + // Create a new interface - m_decoder = ememory::makeShared(); + if (m_decoder == nullptr) { + m_decoder = ememory::makeShared(); + } if (m_decoder == nullptr) { APPL_ERROR("Can not create sharedPtr on decoder ..."); return; @@ -126,7 +131,7 @@ void appl::widget::VideoDisplay::play() { m_decoder->audioGetFormat(), "speaker"); if(m_audioInterface == nullptr) { - APPL_ERROR("Can not creata Audio interface"); + APPL_ERROR("Can not create Audio interface"); } m_audioInterface->setReadwrite(); m_audioInterface->start(); @@ -145,9 +150,8 @@ void appl::widget::VideoDisplay::stop() { if ( m_decoder != nullptr && m_decoder->getState() != gale::Thread::state::stop) { APPL_ERROR("Stop Decoder"); - // stop it ... and request seet at 0 position ... - m_decoder->seek(echrono::Duration(0)); m_decoder->stop(); + m_currentTime = 0; } if (m_audioInterface != nullptr) { APPL_ERROR("Stop audio interface"); diff --git a/tools/player-video/data/gui-connection.xml b/tools/player-video/data/gui-connection.xml index ac8cd43..48ed91a 100644 --- a/tools/player-video/data/gui-connection.xml +++ b/tools/player-video/data/gui-connection.xml @@ -1,13 +1,13 @@ - + - - diff --git a/tools/player-video/data/gui-player.xml b/tools/player-video/data/gui-player.xml new file mode 100644 index 0000000..5234918 --- /dev/null +++ b/tools/player-video/data/gui-player.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/player-video/data/gui.xml b/tools/player-video/data/gui.xml index 94684a6..6065112 100644 --- a/tools/player-video/data/gui.xml +++ b/tools/player-video/data/gui.xml @@ -1,84 +1,83 @@ - - - - - - - - - - - - + + + + + + - + + + - + - - + + + + + + + + + + + + + + + - + -