Commit 218f7b1b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

LibVLC provides time and position when changing position. Now we use it.

parent cce937e6
...@@ -100,10 +100,10 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev ...@@ -100,10 +100,10 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
self->emit endReached(); self->emit endReached();
break; break;
case libvlc_MediaPlayerTimeChanged: case libvlc_MediaPlayerTimeChanged:
self->emit timeChanged(); self->emit timeChanged( event->u.media_player_time_changed.new_time / 1000 );
break; break;
case libvlc_MediaPlayerPositionChanged: case libvlc_MediaPlayerPositionChanged:
self->emit positionChanged(); self->emit positionChanged( event->u.media_player_position_changed.new_position );
break; break;
case libvlc_MediaPlayerLengthChanged: case libvlc_MediaPlayerLengthChanged:
self->emit lengthChanged(); self->emit lengthChanged();
...@@ -209,17 +209,6 @@ void MediaPlayer::setDrawable( uint32_t drawable ...@@ -209,17 +209,6 @@ void MediaPlayer::setDrawable( uint32_t drawable
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
} }
void MediaPlayer::timeChangedFilter()
{
// Don't flood the gui with too many signals
qint64 currentTime = getTime() / 100;
static qint64 lastTime = 0;
if ( currentTime != lastTime )
emit timeChanged();
lastTime = currentTime;
}
void MediaPlayer::setMedia( Media* media ) void MediaPlayer::setMedia( Media* media )
{ {
libvlc_media_player_set_media( m_internalPtr, media->getInternalPtr(), m_ex); libvlc_media_player_set_media( m_internalPtr, media->getInternalPtr(), m_ex);
......
...@@ -65,7 +65,6 @@ namespace LibVLCpp ...@@ -65,7 +65,6 @@ namespace LibVLCpp
private: private:
static void callbacks( const libvlc_event_t* event, void* self ); static void callbacks( const libvlc_event_t* event, void* self );
void timeChangedFilter();
Exception m_ex; Exception m_ex;
libvlc_event_manager_t* p_em; libvlc_event_manager_t* p_em;
...@@ -73,12 +72,12 @@ namespace LibVLCpp ...@@ -73,12 +72,12 @@ namespace LibVLCpp
signals: signals:
void snapshotTaken(); void snapshotTaken();
void timeChanged(); void timeChanged( qint64 );
void playing(); void playing();
void paused(); void paused();
void stopped(); void stopped();
void endReached(); void endReached();
void positionChanged(); void positionChanged( float );
void lengthChanged(); void lengthChanged();
}; };
} }
......
...@@ -135,7 +135,7 @@ void MetaDataWorker::getMetaData() ...@@ -135,7 +135,7 @@ void MetaDataWorker::getMetaData()
//Setting time for snapshot : //Setting time for snapshot :
if ( m_media->getFileType() == Media::Video ) if ( m_media->getFileType() == Media::Video )
{ {
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) ); connect( m_mediaPlayer, SIGNAL( positionChanged( float ) ), this, SLOT( renderSnapshot() ) );
m_mediaPlayer->setTime( m_mediaPlayer->getLength() / 3 ); m_mediaPlayer->setTime( m_mediaPlayer->getLength() / 3 );
} }
else else
...@@ -146,7 +146,7 @@ void MetaDataWorker::getMetaData() ...@@ -146,7 +146,7 @@ void MetaDataWorker::getMetaData()
void MetaDataWorker::renderSnapshot() void MetaDataWorker::renderSnapshot()
{ {
if ( m_media->getFileType() == Media::Video ) if ( m_media->getFileType() == Media::Video )
disconnect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) ); disconnect( m_mediaPlayer, SIGNAL( positionChanged( float ) ), this, SLOT( renderSnapshot() ) );
else else
disconnect( this, SIGNAL( snapshotRequested() ), this, SLOT( renderSnapshot() ) ); disconnect( this, SIGNAL( snapshotRequested() ), this, SLOT( renderSnapshot() ) );
QTemporaryFile tmp; QTemporaryFile tmp;
......
...@@ -39,7 +39,7 @@ ClipRenderer::ClipRenderer() : ...@@ -39,7 +39,7 @@ ClipRenderer::ClipRenderer() :
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) ); connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) ); connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) ); connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( timeChanged() ), this, SLOT( __timeChanged() ) ); connect( m_mediaPlayer, SIGNAL( timeChanged( qint64 ) ), this, SLOT( __timeChanged( qint64 ) ) );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( __endReached() ) ); connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( __endReached() ) );
} }
...@@ -262,12 +262,12 @@ void ClipRenderer::__videoPlaying() ...@@ -262,12 +262,12 @@ void ClipRenderer::__videoPlaying()
// emit frameChanged( pos, MainWorkflow::Renderer ); // emit frameChanged( pos, MainWorkflow::Renderer );
//} //}
void ClipRenderer::__timeChanged() void ClipRenderer::__timeChanged( qint64 time )
{ {
float fps = (qreal)m_mediaPlayer->getFps(); float fps = (qreal)m_mediaPlayer->getFps();
if ( fps < 0.1f ) if ( fps < 0.1f )
fps = m_selectedMedia->getFps(); fps = m_selectedMedia->getFps();
qint64 f = qRound64( (qreal)m_mediaPlayer->getTime() / 1000.0 * fps ); qint64 f = qRound64( (qreal)time / 1000.0 * fps );
emit frameChanged( f, MainWorkflow::Renderer ); emit frameChanged( f, MainWorkflow::Renderer );
} }
......
...@@ -71,7 +71,7 @@ public slots: ...@@ -71,7 +71,7 @@ public slots:
virtual void previewWidgetCursorChanged( qint64 newFrame ); virtual void previewWidgetCursorChanged( qint64 newFrame );
// void __positionChanged(); // void __positionChanged();
void __timeChanged(); void __timeChanged( qint64 time );
void __videoPaused(); void __videoPaused();
void __videoPlaying(); void __videoPlaying();
void __endReached(); void __endReached();
......
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