Commit 49f9a87a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Cleaned some "//TODO" Snapshot is (mostly) working (...)

Metadata can be retrived, it just lacks some setters/getters :)
parent 20b131a7
......@@ -23,6 +23,8 @@
#include <QtDebug>
#include "Clip.h"
QPixmap* Clip::defaultSnapshot = NULL;
Clip::Clip( const QString& mrl )
: m_vlcMedia( NULL ), m_mrl( mrl ), m_snapshot( NULL )
{
......@@ -62,17 +64,19 @@ void Clip::addParam( const QString& param )
void Clip::setSnapshot( QPixmap* snapshot )
{
//TODO: check for mem leaks.
if ( m_snapshot != NULL )
delete m_snapshot;
m_snapshot = snapshot;
emit snapshotChanged();
}
const QPixmap& Clip::getSnapshot() const
{
if ( m_snapshot )
if ( m_snapshot != NULL )
return *m_snapshot;
//TODO: instanciate this as a static pixmap
return QPixmap( ":/images/images/vlmc.png" );
if ( Clip::defaultSnapshot == NULL )
Clip::defaultSnapshot = new QPixmap( ":/images/images/vlmc.png" );
return *Clip::defaultSnapshot;
}
const QUuid& Clip::getUuid() const
......
......@@ -58,6 +58,7 @@ protected:
QList<QString> m_parameters;
QPixmap* m_snapshot;
QUuid m_uuid;
static QPixmap* defaultSnapshot;
signals:
void snapshotChanged();
......
......@@ -93,7 +93,8 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
self->emit endReached();
// case libvlc_MediaPlayerEncounteredError:
case libvlc_MediaPlayerTimeChanged:
self->timeChangedFilter();
//self->timeChangedFilter();
self->emit timeChanged();
break;
case libvlc_MediaPlayerPositionChanged:
self->emit positionChanged();
......
......@@ -42,37 +42,44 @@ void MetaDataManager::run()
m_mediaPlayer->setMedia( m_currentClip->getVLCMedia() );
m_mediaPlayer->play();
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( renderSnapshot() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( getMetaData() ) );
}
usleep( 100 );
usleep( 10000 );
}
qDebug() << "Exiting thread";
return;
}
void MetaDataManager::renderSnapshot()
void MetaDataManager::getMetaData()
{
m_mediaPlayer->setTime( m_mediaPlayer->getLength() / 3 );
disconnect( this, SLOT( getMetaData() ) );
m_nextMedia = true;
qDebug() << "Length:" << m_mediaPlayer->getLength();
//FIXME: add a signal / slot for time changed.
sleep(1);
//Setting time for snapshot :
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
m_mediaPlayer->setTime( m_mediaPlayer->getLength() / 3 );
}
void MetaDataManager::renderSnapshot()
{
disconnect( this, SLOT( renderSnapshot() ) );
QTemporaryFile tmp;
tmp.setAutoRemove( false );
tmp.open();
strncpy(m_tmpSnapshotFilename, tmp.fileName().toStdString().c_str(), tmp.fileName().length());
connect( m_mediaPlayer, SIGNAL( snapshotTaken() ), this, SLOT( setSnapshotInIcon() ) );
connect( m_mediaPlayer, SIGNAL( snapshotTaken() ), this, SLOT( setSnapshot() ) );
//The slot should be triggered in this methode
m_mediaPlayer->takeSnapshot( m_tmpSnapshotFilename, 32, 32 );
//Snapshot slot should has been called (but maybe not in next version...)
}
void MetaDataManager::setSnapshotInIcon()
void MetaDataManager::setSnapshot()
{
m_currentClip->setSnapshot( new QPixmap( m_tmpSnapshotFilename ) );
m_nextMedia = true;
disconnect( this, SLOT( setSnapshotInIcon() ) );
disconnect( this, SLOT( setSnapshot() ) );
m_mediaPlayer->stop();
}
......@@ -18,7 +18,7 @@ class MetaDataManager : public QThread
~MetaDataManager();
private:
virtual void run();
virtual void run();
private:
LibVLCpp::MediaPlayer* m_mediaPlayer;
......@@ -34,9 +34,10 @@ class MetaDataManager : public QThread
char* m_tmpSnapshotFilename;
private slots:
void listViewMediaAdded( Clip* );
void renderSnapshot();
void setSnapshotInIcon();
void getMetaData();
void listViewMediaAdded( Clip* );
void setSnapshot();
};
#endif // METADATAMANAGER_H
......@@ -68,7 +68,8 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
mimeData->setText( static_cast<ListViewMediaItem*>( currentItem() )->getClip()->getUuid() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
//TODO: get the snapshot.
const QPixmap& dragPixmap = static_cast<ListViewMediaItem*>( currentItem() )->getClip()->getSnapshot();
drag->setPixmap( dragPixmap.scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment