#include "SmilVideoItemView.h"
#include "Logger.h"
#include "FileUtils.h"
+#include "PathUtils.h"
#include "MediaPlayer.h"
#include "MediaUtils.h"
#include <notification.h>
m_HasInvalidFiles = true;
return;
}
- SmilVideoItemView *item = new SmilVideoItemView(getBox(), width, height);
+
+ std::string thumbPath = FileUtils::genUniqueFilePath(PathUtils::getDataPath(""), "thumbnail.jpg");
+ if (!thumbPath.empty())
+ MediaUtils::getVideoFrame(m_MediaPath, thumbPath);
+
+ SmilVideoItemView *item = new SmilVideoItemView(getBox(), width, height, thumbPath);
+ remove(thumbPath.c_str());
m_pVideoSink = item->getVideoSink();
item->show();
appendItem(*item);
: public View
{
public:
- SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight);
+ SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight, const std::string &thumbPath);
virtual ~SmilVideoItemView();
Evas_Object *getVideoSink() const;
private:
- Evas_Object *createImage(Evas_Object *parent, int width, int height);
+ Evas_Object *createImage(Evas_Object *parent, int width, int height, const std::string &thumbPath);
private:
Evas_Object *m_pVideoSink;
}
}
-SmilVideoItemView::SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight)
+SmilVideoItemView::SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight, const std::string &thumbPath)
: m_pVideoSink(nullptr)
{
int w = 0;
getResizedSize(videoWidth, videoHeight, w, h);
setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_video_item"));
- Evas_Object *image = createImage(getEo(), w, h);
+ Evas_Object *image = createImage(getEo(), w, h, thumbPath);
setContent(image, "swallow.thumbnail");
}
return m_pVideoSink;
}
-Evas_Object *SmilVideoItemView::createImage(Evas_Object *parent, int width, int height)
+Evas_Object *SmilVideoItemView::createImage(Evas_Object *parent, int width, int height, const std::string &thumbPath)
{
Evas *evas = evas_object_evas_get(parent);
m_pVideoSink = evas_object_image_filled_add(evas);
- expand(m_pVideoSink);
+ evas_object_image_file_set(m_pVideoSink, thumbPath.c_str(), nullptr);
+ evas_object_image_fill_set(m_pVideoSink, 0, 0, width, height);
evas_object_size_hint_min_set(m_pVideoSink, width, height);
evas_object_size_hint_max_set(m_pVideoSink, width, height);
evas_object_show(m_pVideoSink);