diff --git a/tools/gateway/appl/GateWay.cpp b/tools/gateway/appl/GateWay.cpp index 9d5c97b..6df5ef1 100644 --- a/tools/gateway/appl/GateWay.cpp +++ b/tools/gateway/appl/GateWay.cpp @@ -55,6 +55,11 @@ namespace appl { while (m_threadRunning == true) { // READ section data: enet::Tcp data = std::move(m_interface.waitNext()); + if (data.getConnectionStatus() != enet::Tcp::status::link) { + APPL_CRITICAL("New TCP connection (DEAD ....) ==> gateway is dead ..."); + // TODO: Check interaface: if (m_interface. + std::this_thread::sleep_for(std::chrono::milliseconds(300)); + } APPL_VERBOSE("New connection"); m_gateway->newDirectInterface(std::move(data)); } diff --git a/tools/player-video/appl/ClientProperty.cpp b/tools/player-video/appl/ClientProperty.cpp index d1c36e6..80f5fa0 100644 --- a/tools/player-video/appl/ClientProperty.cpp +++ b/tools/player-video/appl/ClientProperty.cpp @@ -97,6 +97,8 @@ void appl::ClientProperty::connect() { void appl::ClientProperty::setLogin(std::string _login) { fromUser = ""; toUser = ""; + address = ""; + port = 0; // separate loggin and IP adress ... std::string login; std::vector listElem = etk::split(_login, '~'); diff --git a/tools/player-video/appl/Main.cpp b/tools/player-video/appl/Main.cpp index 2c78b98..6bafaae 100644 --- a/tools/player-video/appl/Main.cpp +++ b/tools/player-video/appl/Main.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include namespace appl { @@ -76,6 +77,7 @@ namespace appl { appl::widget::Player::createManagerWidget(_context.getWidgetManager()); appl::widget::ProgressBar::createManagerWidget(_context.getWidgetManager()); appl::widget::VolumeBar::createManagerWidget(_context.getWidgetManager()); + appl::widget::UpBar::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/Windows.cpp b/tools/player-video/appl/Windows.cpp index 72cce91..525ab27 100644 --- a/tools/player-video/appl/Windows.cpp +++ b/tools/player-video/appl/Windows.cpp @@ -81,7 +81,9 @@ void appl::Windows::init() { drawWidgetTree(); m_listViewer = ememory::dynamicPointerCast(m_composer->getSubObjectNamed("ws-name-list-viewer")); - m_listViewer->signalSelect.connect(sharedFromThis(), &appl::Windows::onCallbackSelectMedia); + if (m_listViewer != nullptr) { + m_listViewer->signalSelect.connect(sharedFromThis(), &appl::Windows::onCallbackSelectMedia); + } subBind(ewol::widget::Button, "bt-film-picture", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectFilms); @@ -115,6 +117,12 @@ void appl::Windows::init() { } } } + m_player = ememory::dynamicPointerCast(m_composer->getSubObjectNamed("ws-name-player")); + if (m_player != nullptr) { + m_player->signalPrevious.connect(sharedFromThis(), &appl::Windows::onCallbackPlayerPrevious); + m_player->signalNext.connect(sharedFromThis(), &appl::Windows::onCallbackPlayerNext); + m_player->signalFinished.connect(sharedFromThis(), &appl::Windows::onCallbackPlayerFinished); + } } @@ -125,6 +133,9 @@ void appl::Windows::onCallbackShortCut(const std::string& _value) { void appl::Windows::onCallbackMenuEvent(const std::string& _value) { APPL_WARNING("Event from Menu : " << _value); + if (m_player != nullptr) { + m_player->stop(); + } if (_value == "menu:connect") { appl::widget::ConnectionShared tmpWidget = appl::widget::Connection::create(); if (tmpWidget == nullptr) { @@ -169,8 +180,6 @@ void appl::Windows::onCallbackMenuEvent(const std::string& _value) { } 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(""); @@ -300,9 +309,37 @@ void appl::Windows::onCallbackSelectSourses() { void appl::Windows::onCallbackSelectMedia(const uint32_t& _value) { ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-player"); - ememory::SharedPtr tmpPlayer = ememory::dynamicPointerCast(getSubObjectNamed("ws-name-player")); - if (tmpPlayer != nullptr) { - tmpPlayer->playStream(m_clientProp, _value); + if (m_player != nullptr) { + m_player->playStream(m_clientProp, _value); } } +void appl::Windows::onCallbackPlayerPrevious() { + if (m_player != nullptr) { + m_player->stop(); + } + if (m_listViewer != nullptr) { + if (m_listViewer->previous() == false) { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + } + } +} + +void appl::Windows::onCallbackPlayerNext() { + if (m_player != nullptr) { + m_player->stop(); + } + if (m_listViewer != nullptr) { + if (m_listViewer->next() == false) { + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + } + } +} + +void appl::Windows::onCallbackPlayerFinished() { + if (m_player != nullptr) { + m_player->stop(); + } + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); +} + diff --git a/tools/player-video/appl/Windows.hpp b/tools/player-video/appl/Windows.hpp index 5d04a96..24448d2 100644 --- a/tools/player-video/appl/Windows.hpp +++ b/tools/player-video/appl/Windows.hpp @@ -8,6 +8,8 @@ #include #include #include +#include + namespace appl { class Windows; @@ -20,6 +22,7 @@ namespace appl { ewol::widget::ComposerShared m_composer; ememory::SharedPtr m_clientProp; appl::widget::ListViewerShared m_listViewer; + appl::widget::PlayerShared m_player; std::vector m_list; int32_t m_id; public: @@ -55,6 +58,8 @@ namespace appl { void onCallbackSelectHome() { onCallbackMenuEvent("menu:home"); } + void onCallbackPlayerPrevious(); + void onCallbackPlayerNext(); + void onCallbackPlayerFinished(); }; } - diff --git a/tools/player-video/appl/widget/ListViewer.cpp b/tools/player-video/appl/widget/ListViewer.cpp index e3b23ef..1adbe25 100644 --- a/tools/player-video/appl/widget/ListViewer.cpp +++ b/tools/player-video/appl/widget/ListViewer.cpp @@ -494,7 +494,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { } else if (etk::start_with(m_property->m_mineType, "audio") == true) { m_image.setSource("DATA:MusicNote.svg", 128); } else { - APPL_INFO("Set image: Unknow type '" << m_property->m_mineType << "'"); + APPL_DEBUG("Set image: Unknow type '" << m_property->m_mineType << "'"); m_image.setSource("DATA:Home.svg", 128); } } else { @@ -549,6 +549,7 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { } fullTitle += prop->m_title; APPL_DEBUG("info element : " << prop->m_id << " title: " << fullTitle); + m_currentPayed = prop->m_id; signalSelect.emit(prop->m_id); } else if (m_listDisplay[findId]->m_propertyGroup != nullptr) { ememory::SharedPtr prop = m_listDisplay[findId]->m_propertyGroup; @@ -567,4 +568,50 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { } } return false; -} \ No newline at end of file +} + +bool appl::widget::ListViewer::previous() { + for (int64_t iii=0; iiim_id == m_currentPayed) { + // Start search ... + --iii; + while(iii>=0) { + if (m_listElement[iii] == nullptr) { + --iii; + continue; + } + m_currentPayed = m_listElement[iii]->m_id; + signalSelect.emit(m_currentPayed); + return true; + } + return false; + } + } + return false; +} + +bool appl::widget::ListViewer::next() { + for (size_t iii=0; iiim_id == m_currentPayed) { + // Start search ... + ++iii; + while(iiim_id; + signalSelect.emit(m_currentPayed); + return true; + } + return false; + } + } + return false; +} diff --git a/tools/player-video/appl/widget/ListViewer.hpp b/tools/player-video/appl/widget/ListViewer.hpp index 72030bb..727c4c2 100644 --- a/tools/player-video/appl/widget/ListViewer.hpp +++ b/tools/player-video/appl/widget/ListViewer.hpp @@ -86,6 +86,7 @@ namespace appl { std::string m_currentFilter; std::string m_currentGroup; std::vector> m_listDisplay; //!< list of element in the current local display + uint64_t m_currentPayed; protected: //! @brief constructor ListViewer(); @@ -104,6 +105,19 @@ namespace appl { void searchElements(std::string _filter=""); void searchElementsInternal(const std::string& _filter, const std::string& _group=""); bool onEventInput(const ewol::event::Input& _event) override; + public: + /** + * @brief Generate the event with the previous file property + * @return true We find an element + * @return false We find nothing + */ + bool previous(); + /** + * @brief Generate the event with the next file property + * @return true We find an element + * @return false We find nothing + */ + bool next(); }; } } diff --git a/tools/player-video/appl/widget/Player.cpp b/tools/player-video/appl/widget/Player.cpp index 8a73616..654ecf5 100644 --- a/tools/player-video/appl/widget/Player.cpp +++ b/tools/player-video/appl/widget/Player.cpp @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -42,10 +43,12 @@ void appl::widget::Player::init() { subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalPosition, sharedFromThis(), &appl::widget::Player::onCallbackPosition); subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalDuration, sharedFromThis(), &appl::widget::Player::onCallbackDuration); + subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFinish, sharedFromThis(), &appl::widget::Player::onCallbackFinished); subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFps, sharedFromThis(), &appl::widget::Player::onCallbackFPS); subBind(appl::widget::ProgressBar, "[" + etk::to_string(getId()) + "]appl-player-progress-bar", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackSeekRequest); - subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-player-volume", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackVolumeRequest); + subBind(appl::widget::UpBar, "[" + etk::to_string(getId()) + "]appl-player-volume", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackVolumeRequest); + subBind(appl::widget::UpBar, "[" + etk::to_string(getId()) + "]appl-player-light", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackLightRequest); m_display = ememory::dynamicPointerCast(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display")); m_progress = ememory::dynamicPointerCast(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar")); @@ -107,6 +110,19 @@ static std::string timeToStaticString(const echrono::Duration& _time) { return out; } +void appl::widget::Player::onCallbackFinished() { + if (m_progress != nullptr) { + std::vector> tmp; + m_progress->setRangeAvaillable(tmp); + m_progress->propertyValue.set(0); + m_progress->propertyMaximum.set(0); + } + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-time", "value", "--:--"); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-duration", "value", "--:--"); + signalFinished.emit(); +} + + void appl::widget::Player::onCallbackDuration(const echrono::Duration& _time) { //APPL_ERROR("duration = " << _time); if (m_progress != nullptr) { @@ -146,17 +162,34 @@ void appl::widget::Player::onCallbackVolumeRequest(const float& _value) { if (m_display != nullptr) { m_display->changeVolume(_value); } - std::string display = etk::to_string(int32_t(_value)) + "." + etk::to_string(std::abs(int32_t(_value*10.0f)-int32_t(_value)*10)); - - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-volume", "value", display + " dB"); } +void appl::widget::Player::onCallbackLightRequest(const float& _value) { + APPL_DEBUG("==========================================================================="); + APPL_DEBUG("volume change value=" << _value << " %"); + APPL_DEBUG("==========================================================================="); + if (m_display != nullptr) { + m_display->changeLight(_value); + } +} + + + + void appl::widget::Player::onCallbackFPS(const int32_t& _fps) { APPL_DEBUG("FPS = " << _fps); propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-fps", "value", "FPS=" + etk::to_string(_fps) + ""); } +void appl::widget::Player::stop() { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false"); + if (m_display == nullptr) { + return; + } + m_display->stop(); +} + void appl::widget::Player::suspend() { propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false"); if (m_display == nullptr) { diff --git a/tools/player-video/appl/widget/Player.hpp b/tools/player-video/appl/widget/Player.hpp index 22af181..91c50e3 100644 --- a/tools/player-video/appl/widget/Player.hpp +++ b/tools/player-video/appl/widget/Player.hpp @@ -37,6 +37,7 @@ namespace appl { ememory::SharedPtr m_progress; //!< Display widget public: void playStream(ememory::SharedPtr _property, uint32_t _mediaId); + void stop(); void suspend(); public: void onGetFocus() override; @@ -49,7 +50,9 @@ namespace appl { void onCallbackDuration(const echrono::Duration& _value); void onCallbackSeekRequest(const float& _value); void onCallbackVolumeRequest(const float& _value); + void onCallbackLightRequest(const float& _value); void onCallbackFPS(const int32_t& _fps); + void onCallbackFinished(); }; }; }; diff --git a/tools/player-video/appl/widget/UpBar.cpp b/tools/player-video/appl/widget/UpBar.cpp new file mode 100644 index 0000000..e21cc35 --- /dev/null +++ b/tools/player-video/appl/widget/UpBar.cpp @@ -0,0 +1,106 @@ +/** @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 +#include + +appl::widget::UpBar::UpBar() : + propertyType(this, "bar-type", + "sound", + "type of the element", + &appl::widget::UpBar::onChangePropertyType), + propertyValue(this, "value", + 0, + "value of the bar", + &appl::widget::UpBar::onChangePropertyValue), + signalChange(this, "value", "Value of the upbar") { + addObjectType("appl::widget::UpBar"); +} + +void appl::widget::UpBar::init() { + ewol::widget::Composer::init(); + if (*propertySubFile == "") { + if (*propertyType == "volume") { + propertySubFile.set("DATA:gui-volume.xml"); + } else if (*propertyType == "light") { + propertySubFile.set("DATA:gui-light.xml"); + } else { + APPL_ERROR("can not set the mode of upBar"); + } + } + if (*propertyType == "volume") { + subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackVolumeRequest); + } else { + subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackLightRequest); + } + subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalHide, sharedFromThis(), &appl::widget::UpBar::onCallbackHide); + markToRedraw(); +} + +appl::widget::UpBar::~UpBar() { + +} + +void appl::widget::UpBar::onCallbackVolumeRequest(const float& _value) { + APPL_DEBUG("==========================================================================="); + APPL_DEBUG("volume change value=" << _value << " dB"); + APPL_DEBUG("==========================================================================="); + signalChange.emit(_value); + std::string display = etk::to_string(int32_t(_value)) + "." + etk::to_string(std::abs(int32_t(_value*10.0f)-int32_t(_value)*10)); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "value", display + " dB"); +} + +void appl::widget::UpBar::onCallbackLightRequest(const float& _value) { + APPL_DEBUG("==========================================================================="); + APPL_DEBUG("Light change value=" << _value << " %"); + APPL_DEBUG("==========================================================================="); + signalChange.emit(float(int32_t(_value))*0.01f); + std::string display = etk::to_string(int32_t(_value)); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "value", display + " %"); +} + +void appl::widget::UpBar::onCallbackHide(const float& _value) { + if (_value == 0.0f) { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "hide", etk::to_string(true)); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-image", "hide", etk::to_string(true)); + } else { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "hide", etk::to_string(false)); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-image", "hide", etk::to_string(false)); + } +} + + +void appl::widget::UpBar::onChangePropertyType() { + +} + +void appl::widget::UpBar::onChangePropertyValue() { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-range", "value", etk::to_string(*propertyValue)); + if (*propertyType == "volume") { + onCallbackVolumeRequest(*propertyValue); + } else { + onCallbackLightRequest(*propertyValue); + } + return; +} \ No newline at end of file diff --git a/tools/player-video/appl/widget/UpBar.hpp b/tools/player-video/appl/widget/UpBar.hpp new file mode 100644 index 0000000..8962d67 --- /dev/null +++ b/tools/player-video/appl/widget/UpBar.hpp @@ -0,0 +1,42 @@ +/** @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 +#include +#include + +namespace appl { + namespace widget { + class UpBar; + using UpBarShared = ememory::SharedPtr; + using UpBarWeak = ememory::WeakPtr; + class UpBar : public ewol::widget::Composer { + public: // properties + eproperty::Value propertyType; //!< Type of the bar + eproperty::Value propertyValue; //!< value of the bar ... + public: // signals + esignal::Signal signalChange; //!< Value of the bar + protected: + UpBar(); + void init() override; + public: + DECLARE_WIDGET_FACTORY(UpBar, "appl_UpBar"); + virtual ~UpBar(); + private: + // callback functions: + void onCallbackLightRequest(const float& _value); + void onCallbackVolumeRequest(const float& _value); + void onCallbackHide(const float& _value); + void onChangePropertyType(); + void onChangePropertyValue(); + }; + }; +}; diff --git a/tools/player-video/appl/widget/VideoPlayer.cpp b/tools/player-video/appl/widget/VideoPlayer.cpp index 5bbacfa..1afccb0 100644 --- a/tools/player-video/appl/widget/VideoPlayer.cpp +++ b/tools/player-video/appl/widget/VideoPlayer.cpp @@ -20,7 +20,8 @@ const int32_t appl::widget::VideoDisplay::m_vboIdCoordTex(1); const int32_t appl::widget::VideoDisplay::m_vboIdColor(2); #define NB_VBO (3) -appl::widget::VideoDisplay::VideoDisplay() { +appl::widget::VideoDisplay::VideoDisplay() : + m_light(1.0f) { addObjectType("appl::widget::VideoDisplay"); m_color = etk::color::white; m_nbFramePushed = 0; @@ -126,22 +127,6 @@ void appl::widget::VideoDisplay::play() { APPL_DEBUG("Already started"); return; } - /* - APPL_ERROR("=========================================================="); - APPL_ERROR("== Presence of Audio: " << m_decoder->haveAudio() << " =="); - APPL_ERROR("=========================================================="); - if (m_decoder->haveAudio() == true) { - m_audioInterface = m_audioManager->createOutput(m_decoder->audioGetSampleRate(), - m_decoder->audioGetChannelMap(), - m_decoder->audioGetFormat(), - "speaker"); - if(m_audioInterface == nullptr) { - APPL_ERROR("Can not create Audio interface"); - } - m_audioInterface->setReadwrite(); - m_audioInterface->start(); - } - */ // Start decoder, this is maybe not the good point, but if we configure a decoder, it is to use it ... m_decoder->start(); //TODO: Set an option to river to auto-generate dot: m_audioManager->generateDotAll("out/local_player_flow.dot"); @@ -152,6 +137,13 @@ void appl::widget::VideoDisplay::changeVolume(const float& _value) { m_audioManager->setVolume("MASTER", _value); } } +void appl::widget::VideoDisplay::changeLight(const float& _value) { + m_light = _value; + m_color.setR(m_light); + m_color.setG(m_light); + m_color.setB(m_light); + m_color.setA(1.0); +} void appl::widget::VideoDisplay::pause() { m_isPalying = false; @@ -313,7 +305,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) int32_t idSlot = m_decoder->audioGetOlderSlot(); if ( idSlot != -1 && m_currentTime > m_decoder->m_audioPool[idSlot].m_time) { - APPL_WARNING("Get Slot AUDIO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time); + APPL_VERBOSE("Get Slot AUDIO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time); if (m_audioInterface == nullptr) { // start audio interface the first time we need it APPL_ERROR("=========================================================="); @@ -345,7 +337,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) // check the slot is valid and check display time of the element: if ( idSlot != -1 && m_currentTime > m_decoder->m_videoPool[idSlot].m_time) { - APPL_WARNING("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time); + APPL_VERBOSE("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time); m_resource->get().swap(m_decoder->m_videoPool[idSlot].m_image); m_imageSize = m_resource->get().getSize(); ivec2 tmpSize = m_decoder->m_videoPool[idSlot].m_imagerealSize; @@ -375,9 +367,10 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) } // TODO : Chek if this is needed, the display configuration not change too much ... markToRedraw(); + // TODO: understand why this take 4 seconds to detect end ... maybe check end with the end read of the file ... if ( m_haveDuration == true && m_decoder->getDuration() > echrono::milliseconds(10)) { - if (m_currentTime >= m_decoder->getDuration() + echrono::milliseconds(200)) { + if (m_currentTime >= m_decoder->getDuration() /*- echrono::milliseconds(1000)*/) { APPL_WARNING("Finish playing"); signalFinish.emit(); stop(); diff --git a/tools/player-video/appl/widget/VideoPlayer.hpp b/tools/player-video/appl/widget/VideoPlayer.hpp index 1c604b6..bcef62f 100644 --- a/tools/player-video/appl/widget/VideoPlayer.hpp +++ b/tools/player-video/appl/widget/VideoPlayer.hpp @@ -97,6 +97,10 @@ namespace appl { return m_decoder->getDownloadPart(); } void changeVolume(const float& _value); + private: + float m_light; + public: + void changeLight(const float& _value); }; } } diff --git a/tools/player-video/appl/widget/VolumeBar.cpp b/tools/player-video/appl/widget/VolumeBar.cpp index 3000c4b..5791358 100644 --- a/tools/player-video/appl/widget/VolumeBar.cpp +++ b/tools/player-video/appl/widget/VolumeBar.cpp @@ -7,9 +7,11 @@ #include #include +#include appl::widget::VolumeBar::VolumeBar() : signalChange(this, "change", ""), + signalHide(this, "hide", ""), propertyValue(this, "value", 0.0f, "Value of the VolumeBar", @@ -24,7 +26,12 @@ appl::widget::VolumeBar::VolumeBar() : propertyMaximum(this, "max", 5.0f, "Maximum value", - &appl::widget::VolumeBar::onChangePropertyMaximum) { + &appl::widget::VolumeBar::onChangePropertyMaximum), + propertyDanger(this, "danger", + 4.0f, + "Danger value"), + m_isHidden(false), + m_lastEventTime(echrono::Time::now()) { addObjectType("appl::widget::VolumeBar"); m_textColorFg = etk::color::orange; @@ -35,10 +42,25 @@ appl::widget::VolumeBar::VolumeBar() : m_textColorBg.setA(0x3F); propertyCanFocus.setDirectCheck(true); + + m_PCH = getObjectManager().periodicCall.connect(this, &appl::widget::VolumeBar::periodicCall); + // Limit event at 1: setMouseLimit(1); } + +void appl::widget::VolumeBar::periodicCall(const ewol::event::Time& _event) { + if (echrono::Time::now() - m_lastEventTime > echrono::seconds(3)) { + m_isHidden = true; + signalHide.emit(0.0f); + } + if (m_isHidden == true) { + m_PCH.disconnect(); + } + markToRedraw(); +} + appl::widget::VolumeBar::~VolumeBar() { } @@ -51,6 +73,9 @@ void appl::widget::VolumeBar::calculateMinMaxSize() { } void appl::widget::VolumeBar::onDraw() { + if (m_isHidden == true) { + return; + } m_draw.draw(); } @@ -75,7 +100,7 @@ void appl::widget::VolumeBar::onRegenerateDisplay() { m_draw.lineRel(vec2(0.0f, -m_size.y())); #endif // chaneg color whe soud became louder ... - if (*propertyValue > 0.5f) { + if (*propertyValue > *propertyDanger) { m_draw.setColor(m_textColorLoaded); } else { m_draw.setColor(m_textColorDone); @@ -88,6 +113,12 @@ void appl::widget::VolumeBar::onRegenerateDisplay() { } bool appl::widget::VolumeBar::onEventInput(const ewol::event::Input& _event) { + m_lastEventTime = echrono::Time::now(); + if (m_isHidden == true) { + m_isHidden = false; + signalHide.emit(1.0f); + m_PCH = getObjectManager().periodicCall.connect(this, &appl::widget::VolumeBar::periodicCall); + } vec2 relativePos = relativePosition(_event.getPos()); //EWOL_DEBUG("Event on VolumeBar ..." << _event); if (_event.getId() == 1) { diff --git a/tools/player-video/appl/widget/VolumeBar.hpp b/tools/player-video/appl/widget/VolumeBar.hpp index 629663b..69e2ed3 100644 --- a/tools/player-video/appl/widget/VolumeBar.hpp +++ b/tools/player-video/appl/widget/VolumeBar.hpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include namespace appl { @@ -23,12 +25,23 @@ namespace appl { class VolumeBar : public ewol::Widget { public: // signals esignal::Signal signalChange; + esignal::Signal signalHide; //!< Hide value [0..1] ==> 0 is hidden public: //eproperty::Value propertyShape; //!< name of the shape used eproperty::Value propertyValue; //!< current value of the VolumeBar eproperty::Value propertyStep; //!< Up and down step value eproperty::Value propertyMinimum; //!< minimum value of the VolumeBar eproperty::Value propertyMaximum; //!< maximum value of the VolumeBar + eproperty::Value propertyDanger; //!< change color value + private: + bool m_isHidden; + echrono::Time m_lastEventTime; + esignal::Connection m_PCH; //!< Periodic Call Handle to remove it when needed + /** + * @brief Periodic call to update grapgic display + * @param[in] _event Time generic event + */ + void periodicCall(const ewol::event::Time& _event); protected: VolumeBar(); public: diff --git a/tools/player-video/data/Suspend.svg b/tools/player-video/data/Suspend.svg new file mode 100644 index 0000000..af08574 --- /dev/null +++ b/tools/player-video/data/Suspend.svg @@ -0,0 +1,7 @@ + + + + + diff --git a/tools/player-video/data/gui-light.xml b/tools/player-video/data/gui-light.xml new file mode 100644 index 0000000..9853b1d --- /dev/null +++ b/tools/player-video/data/gui-light.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tools/player-video/data/gui-player.xml b/tools/player-video/data/gui-player.xml index a975a16..9d030cb 100644 --- a/tools/player-video/data/gui-player.xml +++ b/tools/player-video/data/gui-player.xml @@ -12,7 +12,8 @@