Commit c6f94706 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Fixed big nasty naughty bugs !

parent 713b9c6d
......@@ -46,9 +46,9 @@ void MediaList::initWatchedEvents()
CheckVlcppException( m_exception );
}
void MediaList::callbacks( const libvlc_event_t* event, void* ptr)
void MediaList::callbacks( const libvlc_event_t* event, void* )
{
MediaList* self = reinterpret_cast< MediaList* >( ptr );
//MediaList* self = reinterpret_cast< MediaList* >( ptr );
switch ( event->type )
{
case libvlc_MediaListPlayerStopped:
......
......@@ -84,14 +84,19 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
// qDebug() << "Paused event";
self->emit paused();
break;
case libvlc_MediaPlayerStopped:
// qDebug() << "Stopped event";
self->emit stopped();
// case libvlc_MediaPlayerForward:
// case libvlc_MediaPlayerBackward:
break;
case libvlc_MediaPlayerEndReached:
self->emit endReached();
// case libvlc_MediaPlayerEncounteredError:
break;
case libvlc_MediaPlayerTimeChanged:
//self->timeChangedFilter();
self->emit timeChanged();
......@@ -131,6 +136,7 @@ void MediaPlayer::play()
void MediaPlayer::pause()
{
qDebug() << "Pausing media";
libvlc_media_player_pause( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
}
......
......@@ -29,7 +29,7 @@
PreviewWidget::PreviewWidget( QWidget *parent ) :
QDialog( parent ),
m_ui( new Ui::PreviewWidget ), m_clipLoaded( false )
m_ui( new Ui::PreviewWidget ), m_clipLoaded( false ), m_videoStopped( true )
{
m_ui->setupUi( this );
m_ui->groupBoxButton->hide();
......@@ -82,18 +82,15 @@ void PreviewWidget::dropEvent( QDropEvent* event )
clip->flushParameters();
m_mediaPlayer->setMedia( clip->getVLCMedia() );
//FIXME Connecting endReached to pause to change icon of playpause button
// this might not work as it works now later!
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT ( videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT ( videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT ( videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( positionChanged() ) );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( endReached() ) );
//TODO: add EndReached event.
m_mediaPlayer->play();
m_clipLoaded = true;
m_videoStopped = false;
event->acceptProposedAction();
}
......@@ -112,7 +109,7 @@ void PreviewWidget::seekSliderPressed()
void PreviewWidget::seekSliderMoved( int )
{
if ( m_clipLoaded == false)
if ( m_clipLoaded == false || m_videoStopped == true )
return ;
if ( m_ui->seekSlider->value() == m_ui->seekSlider->maximum() )
{
......@@ -120,13 +117,17 @@ void PreviewWidget::seekSliderMoved( int )
return;
}
m_endReached = false;
m_mediaPlayer->setPosition( (float)m_ui->seekSlider->value() / 1000.0 );
m_mediaPlayer->setPosition( (float)m_ui->seekSlider->value() / 1000.0 );
}
void PreviewWidget::seekSliderReleased()
{
if ( m_endReached == true )
if ( m_endReached == true && m_videoStopped == false )
{
//When cursor reaches the maximum right, end reached becomes true.
//When we will release our slider, if endReached is true, we actually set the position.
//Otherwise, we do nothing.
//This prevents the video to stop if we put the slider to the maximum right by mistake
m_mediaPlayer->setPosition( (float)m_ui->seekSlider->maximum() / 1000.0 );
m_endReached = false;
}
......@@ -137,6 +138,9 @@ void PreviewWidget::on_pushButtonPlay_clicked()
{
if ( m_clipLoaded == false)
return ;
if ( m_videoStopped == true )
m_videoStopped = false;
if ( m_mediaPlayer->isPlaying() )
m_mediaPlayer->pause();
else
......@@ -155,7 +159,12 @@ void PreviewWidget::videoPlaying()
void PreviewWidget::endReached()
{
//Media player part :
m_mediaPlayer->stop();
m_videoStopped = true;
//GUI part :
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) );
m_ui->seekSlider->setValue( 0 );
}
......@@ -63,6 +63,7 @@ private:
// LibVLCpp::MediaList* m_mediaList;
bool m_clipLoaded;
bool m_endReached;
bool m_videoStopped;
};
#endif // PREVIEWWIDGET_H
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