Commit 0dc91621 authored by Christophe Courtaut's avatar Christophe Courtaut

Change modifiying play icon using vlc events

parent 0a0ca0ca
......@@ -38,6 +38,9 @@ MediaPlayer::MediaPlayer( Media* media, bool playStop /* = true*/ )
libvlc_event_attach( p_em, libvlc_MediaPlayerSnapshotTaken, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerTimeChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPlaying, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPaused, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerStopped, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerEndReached, callbacks, this, m_ex );
}
/**
......@@ -60,11 +63,14 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
case libvlc_MediaPlayerPlaying:
self->emit playing();
break;
// case libvlc_MediaPlayerPaused:
// case libvlc_MediaPlayerStopped:
case libvlc_MediaPlayerPaused:
self->emit paused();
case libvlc_MediaPlayerStopped:
self->emit stopped();
// case libvlc_MediaPlayerForward:
// case libvlc_MediaPlayerBackward:
// case libvlc_MediaPlayerEndReached:
case libvlc_MediaPlayerEndReached:
self->emit endReached();
// case libvlc_MediaPlayerEncounteredError:
case libvlc_MediaPlayerTimeChanged:
self->timeChangedFilter();
......
......@@ -62,6 +62,9 @@ namespace LibVLCpp
void snapshotTaken();
void timeChanged();
void playing();
void paused();
void stopped();
void endReached();
};
}
......
......@@ -83,8 +83,21 @@ void PreviewWidget::dropEvent( QDropEvent* event )
m_currentMedia->loadMedia( "file://" + item->fileInfo()->absoluteFilePath() );
m_currentMedia->setupMedia();
m_currentMedia->setDrawable( m_ui->clipRenderWidget->winId() );
//FIXME Connecting endReached to pause to change icon of playpause button
// this might not work as it works now later!
connect( m_currentMedia->mediaPlayer(),
SIGNAL( endReached() ),
this,
SLOT ( videoPaused() ) );
connect( m_currentMedia->mediaPlayer(),
SIGNAL( stopped() ),
this,
SLOT ( videoPaused() ) );
connect( m_currentMedia->mediaPlayer(),
SIGNAL( playing() ),
this,
SLOT ( videoPlaying() ) );
m_currentMedia->play();
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/pause" ) );
connect( m_currentMedia->mediaPlayer(),
SIGNAL( timeChanged() ),
this,
......@@ -115,11 +128,19 @@ void PreviewWidget::on_pushButtonPlay_clicked()
if ( m_currentMedia->isPlaying() )
{
m_currentMedia->pause();
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) );
}
else
{
m_currentMedia->play();
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/pause" ) );
}
}
void PreviewWidget::videoPaused()
{
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) );
}
void PreviewWidget::videoPlaying()
{
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/pause" ) );
}
......@@ -46,9 +46,11 @@ protected:
virtual void dropEvent( QDropEvent* event );
private slots:
void on_pushButtonPlay_clicked();
void on_pushButtonPlay_clicked();
void videoTimeChanged();
void seekSliderMoved( int value );
void videoPaused();
void videoPlaying();
private:
Ui::PreviewWidget* m_ui;
......
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