[DEV] add the small image in the group

This commit is contained in:
Edouard DUPIN 2017-06-25 15:03:16 +02:00
parent c5f58d6af6
commit ef2b52dc1b
5 changed files with 117 additions and 16 deletions

View File

@ -58,7 +58,8 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map<
&& _path.rfind('.') != 0) {
extention = etk::tolower(std::string(_path.begin()+_path.rfind('.')+1, _path.end()));
}
// internal extention ....
std::string fileName = etk::split(_path, '/').back();
// internal extention ...
if (extention == "sha512") {
return true;
}
@ -67,10 +68,35 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map<
&& extention != "mkv"
&& extention != "mov"
&& extention != "mp4"
&& extention != "ts") {
&& extention != "ts"
&& fileName != "cover_1.jpg"
&& fileName != "cover_1.png"
&& fileName != "cover_1.till"
&& fileName != "cover_1.bmp"
&& fileName != "cover_1.tga") {
APPL_ERROR("Sot send file : " << _path << " Not manage extention...");
return false;
}
if ( fileName == "cover_1.jpg"
|| fileName == "cover_1.png"
|| fileName == "cover_1.till"
|| fileName == "cover_1.bmp"
|| fileName == "cover_1.tga") {
// find a cover...
APPL_INFO("Send cover for: " << _basicKey["series-name"] << " " << _basicKey["saison"]);
if (_basicKey["series-name"] == "") {
APPL_ERROR(" ==> can not asociate at a specific seri");
return false;
}
std::string groupName = _basicKey["series-name"];
if (_basicKey["saison"] != "") {
groupName += ":" + _basicKey["saison"];
}
auto sending = _srv.setGroupCover(zeus::File::create(_path, ""), groupName);
sending.onSignal(progressCallback);
sending.waitFor(echrono::seconds(20000));
return true;
}
std::string storedSha512;
if (etk::FSNodeExist(_path + ".sha512") == true) {
uint64_t time_sha512 = etk::FSNodeGetTimeModified(_path + ".sha512");
@ -123,9 +149,6 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map<
}
// TODO: if the media have meta data ==> this mean that the media already added before ...
// Parse file name:
std::string fileName = etk::split(_path, '/').back();
APPL_INFO("Find fileName : '" << fileName << "'");
// Remove Date (XXXX) or other title
std::vector<std::string> dates;

View File

@ -336,7 +336,50 @@ bool appl::ElementProperty::LoadDataEnded() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_metadataUpdated == appl::statusLoadingData::done;
}
void appl::ElementPropertyGroup::loadData() {
// Check progression status:
{
std::unique_lock<std::mutex> lock(m_mutex);
if (m_metadataUpdated != appl::statusLoadingData::noData) {
return;
}
m_metadataUpdated = appl::statusLoadingData::inProgress;
}
auto tmpProperty = sharedFromThis();
// Get the media
auto futMedia = m_remoteServiceVideo.getGroupCover(m_title, 128);
futMedia.andElse([=](const std::string& _error, const std::string& _help) mutable {
APPL_INFO(" [" << tmpProperty->m_id << "] get cover error on group: " << tmpProperty->m_title << ": " << _help);
{
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
}
m_widget->markToRedraw();
return true;
});
futMedia.andThen([=](zeus::ProxyFile _media) mutable {
APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title);
auto mineTypeFut = _media.getMineType();
std::vector<uint8_t> bufferData = zeus::storeInMemory(_media);
APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " store in memory " << bufferData.size());
std::string mineType = mineTypeFut.wait().get();
APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " 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();
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
return true;
});
}
bool appl::ElementPropertyGroup::LoadDataEnded() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_metadataUpdated == appl::statusLoadingData::done;
}
void appl::widget::ListViewer::backHistory() {
if (m_history.size() == 0) {
@ -395,7 +438,7 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter
}
for (auto &it : returnValues) {
auto elem = ememory::makeShared<ElementPropertyGroup>();
auto elem = ememory::makeShared<ElementPropertyGroup>(remoteServiceVideo, ememory::staticPointerCast<ewol::Widget>(sharedFromThis()));
if (elem == nullptr) {
APPL_ERROR("Can not allocate element... " << it);
continue;
@ -540,6 +583,9 @@ void appl::widget::ListViewer::onRegenerateDisplay() {
}
if (offset + iii < m_listElementGroup.size()) {
elem->m_propertyGroup = m_listElementGroup[offset + iii];
if (elem->m_propertyGroup != nullptr) {
elem->m_propertyGroup->loadData();
}
} else {
elem->m_propertyGroup.reset();
}
@ -678,10 +724,13 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
textToDisplay += "<i>" + m_property->m_description + "</i>";
}
} else {
std::unique_lock<std::mutex> lock(m_propertyGroup->m_mutex);
if (m_propertyGroup->LoadDataEnded() == false) {
textToDisplay += "<br/><b>" + m_propertyGroup->m_title + "</b><br/><i>Loading in progress</i> ...";
} else {
//m_text.setClipping(drawClippingPos, drawClippingSize);
textToDisplay = "<br/><b>" + m_propertyGroup->m_title + "</b><br/>";
}
}
m_text.printDecorated(textToDisplay);
// --------------------------------------------
@ -698,8 +747,16 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
m_image.setSource("DATA:Home.svg", 128);
}
} else {
std::unique_lock<std::mutex> lock(m_propertyGroup->m_mutex);
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);
}
}
}
m_image.setPos(_startPos+vec2(10,10));
m_image.print(vec2(_size.y(), _size.y())-vec2(20,20));

View File

@ -32,7 +32,8 @@ namespace appl {
m_remoteServiceVideo(_remoteServiceVideo),
m_widget(_widget),
m_metadataUpdated(appl::statusLoadingData::noData),
m_nbElementLoaded(0) {
m_nbElementLoaded(0),
m_thumbPresent(false) {
}
public:
@ -44,6 +45,7 @@ namespace appl {
uint64_t m_id; //!< Remote Id of the Media
egami::Image m_thumb; //!< simple image describing the element
bool m_thumbPresent; //!< if true, the Image is loaded
std::string m_title; //!< Title of the Element
std::string m_description; //!< Description of the element
std::string m_serie; //!< Name of the serie or empty
@ -57,12 +59,31 @@ namespace appl {
// TODO: int64_t m_globalPersonalView; //!< number of time this media has been viewed
void loadData();
};
class ElementPropertyGroup {
class ElementPropertyGroup : public ememory::EnableSharedFromThis<appl::ElementPropertyGroup> {
private:
zeus::service::ProxyVideo m_remoteServiceVideo;
ewol::WidgetShared m_widget;
enum appl::statusLoadingData m_metadataUpdated; //!< Check value to know when metadata is getted (like thumb ...)
uint32_t m_nbElementLoaded; //!< this cont the number of lement loaded to set tle media full loaded
public:
ElementPropertyGroup(zeus::service::ProxyVideo& _remoteServiceVideo, ewol::WidgetShared _widget):
m_remoteServiceVideo(_remoteServiceVideo),
m_widget(_widget),
m_metadataUpdated(appl::statusLoadingData::noData),
m_nbElementLoaded(0),
m_thumbPresent(false) {
}
public:
bool LoadDataEnded();
public:
std::mutex m_mutex;
uint64_t m_id; //!< Remote Id of the Media
std::string m_title; //!< Title of the Group
std::string m_filter; //!< element to add in the filter
egami::Image m_thumb; //!< simple image describing the element
bool m_thumbPresent; //!< if true, the Image is loaded
void loadData();
};
class ElementDisplayed {
public:

View File

@ -24,7 +24,7 @@
<spacer expand="true,false" fill="true"/>
<spacer expand="true,false" fill="true"/>
</sizer>
<appl_ProgressBar name="[{ID}]appl-player-progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
<appl_ProgressBar name="[{ID}]appl-player-progress-bar" expand="true,false" fill="true" step="0.01" min="0" min-size="30,30px"/>
<sizer mode="hori" fill="true" expand="true,false">
<label name="[{ID}]appl-player-label-time"/>
<spacer expand="true,false" fill="true"/>

View File

@ -405,10 +405,10 @@ namespace appl {
ememory::SharedPtr<zeus::File> internalGetCover(const std::string& _baseName, const std::string& _mediaString, uint32_t _maxSize) {
if (etk::FSNodeExist(_baseName + _mediaString + ".jpg") == true) {
return zeus::File::create(_baseName + _mediaString + ".jpg", "", "");
return zeus::File::create(_baseName + _mediaString + ".jpg");
}
if (etk::FSNodeExist(_baseName + _mediaString + ".png") == true) {
return zeus::File::create(_baseName + _mediaString + ".jpg", "", "");
return zeus::File::create(_baseName + _mediaString + ".png");
}
throw std::runtime_error("No cover availlable");
}