[DEV] add videoPlayer thumb

This commit is contained in:
Edouard DUPIN 2017-06-28 08:30:03 +02:00
parent ef2b52dc1b
commit ce60711d56
3 changed files with 137 additions and 22 deletions

View File

@ -76,6 +76,7 @@ void appl::ElementProperty::loadData() {
} }
m_metadataUpdated = appl::statusLoadingData::inProgress; m_metadataUpdated = appl::statusLoadingData::inProgress;
} }
int32_t nbCallOfMetaData = 8;
auto tmpProperty = sharedFromThis(); auto tmpProperty = sharedFromThis();
// Get the media // Get the media
zeus::Future<zeus::ProxyMedia> futMedia = m_remoteServiceVideo.get(m_id); zeus::Future<zeus::ProxyMedia> futMedia = m_remoteServiceVideo.get(m_id);
@ -101,7 +102,6 @@ void appl::ElementProperty::loadData() {
m_widget->markToRedraw(); m_widget->markToRedraw();
return true; return true;
} }
int32_t nbCallOfMetaData = 7;
_media.getMetadata("title") _media.getMetadata("title")
.andElse([=](const std::string& _error, const std::string& _help) mutable { .andElse([=](const std::string& _error, const std::string& _help) mutable {
{ {
@ -141,7 +141,7 @@ void appl::ElementProperty::loadData() {
return true; return true;
}) })
.andThen([=](std::string _value) mutable { .andThen([=](std::string _value) mutable {
APPL_ERROR(" [" << tmpProperty->m_id << "] get serie: " << _value); APPL_INFO(" [" << tmpProperty->m_id << "] get serie: " << _value);
{ {
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex); std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_serie = _value; tmpProperty->m_serie = _value;
@ -212,7 +212,7 @@ void appl::ElementProperty::loadData() {
}); });
_media.getMetadata("description") _media.getMetadata("description")
.andElse([=](const std::string& _error, const std::string& _help) mutable { .andElse([=](const std::string& _error, const std::string& _help) mutable {
APPL_ERROR("Get remot error : " << _error << " " << _help << " [BEGIN]"); APPL_INFO("Get remot error : " << _error << " " << _help);
{ {
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex); std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_nbElementLoaded++; tmpProperty->m_nbElementLoaded++;
@ -220,7 +220,6 @@ void appl::ElementProperty::loadData() {
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
} }
} }
APPL_ERROR("Get remot error : " << _error << " " << _help << " [END]");
return true; return true;
}) })
.andThen([=](std::string _value) mutable { .andThen([=](std::string _value) mutable {
@ -330,6 +329,86 @@ void appl::ElementProperty::loadData() {
//elem->m_thumb = remoteServiceVideo.mediaThumbGet(it, 128).wait().get(); //elem->m_thumb = remoteServiceVideo.mediaThumbGet(it, 128).wait().get();
return true; return true;
}); });
auto futMediaCover = m_remoteServiceVideo.getCover(m_id, 128);
futMediaCover.andElse([=](const std::string& _error, const std::string& _help) mutable {
APPL_INFO(" [" << tmpProperty->m_id << "] get cover error: " << tmpProperty->m_id << ": " << _help);
// TODO : Remove this ...
std::this_thread::sleep_for(std::chrono::milliseconds(400));
std::string serie;
{
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
serie = tmpProperty->m_serie;
}
if (serie != "") {
auto futMediaGroupCover = m_remoteServiceVideo.getGroupCover(serie, 128);
futMediaGroupCover.andElse([=](const std::string& _error, const std::string& _help) mutable {
APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group error: " << serie << ": " << _help);
{
m_widget->markToRedraw();
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_nbElementLoaded++;
if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) {
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
}
}
return true;
});
futMediaGroupCover.andThen([=](zeus::ProxyFile _media) mutable {
APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie);
auto mineTypeFut = _media.getMineType();
std::vector<uint8_t> bufferData = zeus::storeInMemory(_media);
APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie << " store in memory " << bufferData.size());
std::string mineType = mineTypeFut.wait().get();
APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie << " mineType '" << mineType << "'");
{
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_thumb = egami::load(mineType, bufferData);
tmpProperty->m_thumbPresent = true;
}
APPL_WARNING("Get the Thumb ... " << tmpProperty->m_title << " ==> " << tmpProperty->m_thumb);
m_widget->markToRedraw();
{
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_nbElementLoaded++;
if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) {
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
}
}
return true;
});
} else {
m_widget->markToRedraw();
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_nbElementLoaded++;
if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) {
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
}
}
return true;
});
futMediaCover.andThen([=](zeus::ProxyFile _media) mutable {
APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id);
auto mineTypeFut = _media.getMineType();
std::vector<uint8_t> bufferData = zeus::storeInMemory(_media);
APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id << " store in memory " << bufferData.size());
std::string mineType = mineTypeFut.wait().get();
APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id << " mineType '" << mineType << "'");
{
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_thumb = egami::load(mineType, bufferData);
tmpProperty->m_thumbPresent = true;
}
APPL_WARNING("Get the Thumb ... " << tmpProperty->m_title << " ==> " << tmpProperty->m_thumb);
m_widget->markToRedraw();
{
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_nbElementLoaded++;
if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) {
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
}
}
return true;
});
} }
bool appl::ElementProperty::LoadDataEnded() { bool appl::ElementProperty::LoadDataEnded() {
@ -737,7 +816,18 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
// -- Display Image... // -- Display Image...
// -------------------------------------------- // --------------------------------------------
if (m_property != nullptr) { if (m_property != nullptr) {
bool haveThumb = false;
if (m_property->LoadDataEnded() == false) {
haveThumb = false;
m_image.setSource("DATA:Home.svg", 128);
} else {
std::unique_lock<std::mutex> lock(m_property->m_mutex); std::unique_lock<std::mutex> lock(m_property->m_mutex);
if (m_property->m_thumbPresent == true) {
haveThumb = true;
m_image.setSource(m_property->m_thumb);
m_image.setPos(_startPos);
m_image.print(vec2(_size.y(), _size.y()));
} else {
if (etk::start_with(m_property->m_mineType, "video") == true) { if (etk::start_with(m_property->m_mineType, "video") == true) {
m_image.setSource("DATA:Video.svg", 128); m_image.setSource("DATA:Video.svg", 128);
} else if (etk::start_with(m_property->m_mineType, "audio") == true) { } else if (etk::start_with(m_property->m_mineType, "audio") == true) {
@ -746,21 +836,33 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
APPL_DEBUG("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); m_image.setSource("DATA:Home.svg", 128);
} }
} else {
if (m_propertyGroup->LoadDataEnded() == false) {
m_image.setSource("DATA:Home.svg", 128);
} else {
std::unique_lock<std::mutex> lock(m_propertyGroup->m_mutex);
if (m_propertyGroup->m_thumbPresent == false) {
m_image.setSource("DATA:Home.svg", 128);
} else {
m_image.setSource(m_propertyGroup->m_thumb);
}
} }
} }
if (haveThumb == false) {
m_image.setPos(_startPos+vec2(10,10)); m_image.setPos(_startPos+vec2(10,10));
m_image.print(vec2(_size.y(), _size.y())-vec2(20,20)); m_image.print(vec2(_size.y(), _size.y())-vec2(20,20));
} }
} else {
bool haveThumb = false;
if (m_propertyGroup->LoadDataEnded() == false) {
haveThumb = false;
} else {
std::unique_lock<std::mutex> lock(m_propertyGroup->m_mutex);
if (m_propertyGroup->m_thumbPresent == true) {
haveThumb = true;
m_image.setSource(m_propertyGroup->m_thumb);
m_image.setPos(_startPos);
m_image.print(vec2(_size.y(), _size.y()));
}
}
if (haveThumb == false) {
m_image.setSource("DATA:Home.svg", 128);
m_image.setPos(_startPos+vec2(10,10));
m_image.print(vec2(_size.y(), _size.y())-vec2(20,20));
}
}
}
bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) {

View File

@ -111,6 +111,19 @@ namespace appl {
} }
}; };
class ElementCache {
private:
std::string m_name;
ememory::SharedPtr<ewol::resource::Texture> m_resource;
echrono::Steady m_lastRequestTime;
};
class CacheImageManager {
private:
std::vector<ElementCache> m_imageCoverGroupCache; //!< All image cash of the group cover
};
namespace widget { namespace widget {
class ListViewer; class ListViewer;
using ListViewerShared = ememory::SharedPtr<appl::widget::ListViewer>; using ListViewerShared = ememory::SharedPtr<appl::widget::ListViewer>;

View File

@ -19,7 +19,7 @@
#include <appl/MediaDecoder.hpp> #include <appl/MediaDecoder.hpp>
#include <appl/widget/ListViewer.hpp> #include <appl/widget/ListViewer.hpp>
#define ZEUS_VIDEO_PLAYER_MULTIPLE_BUFFER (1) #define ZEUS_VIDEO_PLAYER_MULTIPLE_BUFFER (8)
namespace appl { namespace appl {
namespace widget { namespace widget {