[vlmc-devel] Media: Expose the thumbnail as a path to the ML one
Hugo Beauzée-Luyssen
git at videolan.org
Fri Aug 19 11:53:58 CEST 2016
vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Aug 19 11:53:27 2016 +0200| [d6988a2bb354a899a813cf2e54fd2adecf0ca3cc] | committer: Hugo Beauzée-Luyssen
Media: Expose the thumbnail as a path to the ML one
> https://code.videolan.org/videolan/vlmc/commit/d6988a2bb354a899a813cf2e54fd2adecf0ca3cc
---
src/Gui/ClipProperty.cpp | 3 ++-
src/Media/Media.cpp | 23 ++---------------------
src/Media/Media.h | 15 +--------------
3 files changed, 5 insertions(+), 36 deletions(-)
diff --git a/src/Gui/ClipProperty.cpp b/src/Gui/ClipProperty.cpp
index 6c1072d..c60ad79 100644
--- a/src/Gui/ClipProperty.cpp
+++ b/src/Gui/ClipProperty.cpp
@@ -47,7 +47,8 @@ ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) :
setWindowTitle( m_clip->media()->title() + " " + tr( "properties" ) );
//Snapshot
- ui->snapshotLabel->setPixmap( m_clip->media()->snapshot().scaled( 128, 128, Qt::KeepAspectRatio ) );
+ QPixmap snapshot( m_clip->media()->snapshot() );
+ ui->snapshotLabel->setPixmap( snapshot.scaled( 128, 128, Qt::KeepAspectRatio ) );
//Metatags
const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply );
Q_ASSERT( button != nullptr);
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index 15e2bf7..a87ec1e 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -59,10 +59,6 @@ const QString Media::AudioExtensions = "*.a52 *.aac *.ac3 *.aiff *.amr *.aob *
"*.wma *.wv *.xa *.xm";
const QString Media::streamPrefix = "stream://";
-#ifdef HAVE_GUI
-QPixmap* Media::defaultSnapshot = nullptr;
-#endif
-
Media::Media( medialibrary::MediaPtr media, const QUuid& uuid /* = QUuid() */ )
: m_input( nullptr )
, m_mlMedia( media )
@@ -201,26 +197,11 @@ Media::fromVariant( const QVariant& v )
return media;
}
-#ifdef HAVE_GUI
-QPixmap&
+QString
Media::snapshot()
{
- if ( Media::defaultSnapshot == nullptr )
- Media::defaultSnapshot = new QPixmap( ":/images/vlmc" );
-
- if ( m_snapshot.isNull() == true ) {
- int height = 200;
- int width = height * m_input->aspectRatio();
- m_input->setPosition( m_input->length() / 3 );
- QImage img( m_input->image( width, height ), width, height,
- QImage::Format_RGBA8888, []( void* buf ){ delete[] (uchar*) buf; } );
- m_input->setPosition( 0 );
- m_snapshot.convertFromImage( img );
- }
-
- return m_snapshot.isNull() ? *Media::defaultSnapshot : m_snapshot;
+ return QString::fromStdString( m_mlMedia->thumbnail() );
}
-#endif
QSharedPointer<Clip>
Media::loadSubclip( const QVariantMap& m )
diff --git a/src/Media/Media.h b/src/Media/Media.h
index ecb5cac..429f2e5 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -46,11 +46,6 @@
#include <medialibrary/IMedia.h>
#include <medialibrary/IFile.h>
-#ifdef HAVE_GUI
-#include <QPixmap>
-#include <QImage>
-#endif
-
namespace Backend
{
class IInput;
@@ -109,10 +104,7 @@ public:
static QSharedPointer<Media> fromVariant( const QVariant& v );
-#ifdef HAVE_GUI
- // This has to be called from the GUI thread.
- QPixmap& snapshot();
-#endif
+ QString snapshot();
private:
QSharedPointer<Clip> loadSubclip( const QVariantMap& m );
@@ -124,11 +116,6 @@ protected:
Clip* m_baseClip;
QHash<QUuid, QSharedPointer<Clip>> m_clips;
-#ifdef HAVE_GUI
- static QPixmap* defaultSnapshot;
- QPixmap m_snapshot;
-#endif
-
signals:
/**
* \brief This signal should be emitted to tell a new sublip have been added
More information about the Vlmc-devel
mailing list