Commit 811e3b25 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Switch from poster image to video player after video has started playing

If we switch immediately after the play() trigger, a black frame is visible
for a moment, which looks ugly.
parent 02b04e7e
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <kicon.h> #include <kicon.h>
#include <klocale.h> #include <klocale.h>
#include <phonon/mediaobject.h>
#include <phonon/seekslider.h> #include <phonon/seekslider.h>
#include <phonon/videoplayer.h> #include <phonon/videoplayer.h>
...@@ -69,6 +70,7 @@ public: ...@@ -69,6 +70,7 @@ public:
void setPosterImage( const QImage& ); void setPosterImage( const QImage& );
void takeSnapshot(); void takeSnapshot();
void videoStopped(); void videoStopped();
void stateChanged(Phonon::State, Phonon::State);
// slots // slots
void finished(); void finished();
...@@ -113,6 +115,9 @@ void VideoWidget::Private::load() ...@@ -113,6 +115,9 @@ void VideoWidget::Private::load()
else else
player->load( newurl ); player->load( newurl );
connect( player->mediaObject(), SIGNAL( stateChanged( Phonon::State, Phonon::State ) ),
q, SLOT( stateChanged( Phonon::State, Phonon::State ) ) );
seekSlider->setEnabled( true ); seekSlider->setEnabled( true );
} }
...@@ -210,6 +215,12 @@ void VideoWidget::Private::setPosterImage( const QImage &image ) ...@@ -210,6 +215,12 @@ void VideoWidget::Private::setPosterImage( const QImage &image )
q->show(); q->show();
} }
void VideoWidget::Private::stateChanged( Phonon::State newState, Phonon::State )
{
if ( newState == Phonon::PlayingState )
pageLayout->setCurrentIndex( 0 );
}
VideoWidget::VideoWidget( Okular::MovieAnnotation *movieann, Okular::Document *document, QWidget *parent ) VideoWidget::VideoWidget( Okular::MovieAnnotation *movieann, Okular::Document *document, QWidget *parent )
: QWidget( parent ), d( new Private( movieann, document, this ) ) : QWidget( parent ), d( new Private( movieann, document, this ) )
{ {
...@@ -336,7 +347,6 @@ void VideoWidget::pageLeft() ...@@ -336,7 +347,6 @@ void VideoWidget::pageLeft()
void VideoWidget::play() void VideoWidget::play()
{ {
d->pageLayout->setCurrentIndex( 0 );
d->load(); d->load();
d->player->play(); d->player->play();
d->stopAction->setEnabled( true ); d->stopAction->setEnabled( true );
......
...@@ -54,6 +54,7 @@ class VideoWidget : public QWidget ...@@ -54,6 +54,7 @@ class VideoWidget : public QWidget
Q_PRIVATE_SLOT( d, void finished() ) Q_PRIVATE_SLOT( d, void finished() )
Q_PRIVATE_SLOT( d, void playOrPause() ) Q_PRIVATE_SLOT( d, void playOrPause() )
Q_PRIVATE_SLOT( d, void setPosterImage( const QImage& ) ) Q_PRIVATE_SLOT( d, void setPosterImage( const QImage& ) )
Q_PRIVATE_SLOT( d, void stateChanged( Phonon::State, Phonon::State ) )
// private storage // private storage
class Private; class Private;
......
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