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.
This commit is contained in:
Tobias Koenig 2012-08-21 09:37:05 +02:00
parent 02b04e7e9b
commit 811e3b2539
2 changed files with 12 additions and 1 deletions

View file

@ -25,6 +25,7 @@
#include <kicon.h>
#include <klocale.h>
#include <phonon/mediaobject.h>
#include <phonon/seekslider.h>
#include <phonon/videoplayer.h>
@ -69,6 +70,7 @@ public:
void setPosterImage( const QImage& );
void takeSnapshot();
void videoStopped();
void stateChanged(Phonon::State, Phonon::State);
// slots
void finished();
@ -113,6 +115,9 @@ void VideoWidget::Private::load()
else
player->load( newurl );
connect( player->mediaObject(), SIGNAL( stateChanged( Phonon::State, Phonon::State ) ),
q, SLOT( stateChanged( Phonon::State, Phonon::State ) ) );
seekSlider->setEnabled( true );
}
@ -210,6 +215,12 @@ void VideoWidget::Private::setPosterImage( const QImage &image )
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 )
: QWidget( parent ), d( new Private( movieann, document, this ) )
{
@ -336,7 +347,6 @@ void VideoWidget::pageLeft()
void VideoWidget::play()
{
d->pageLayout->setCurrentIndex( 0 );
d->load();
d->player->play();
d->stopAction->setEnabled( true );

View file

@ -54,6 +54,7 @@ class VideoWidget : public QWidget
Q_PRIVATE_SLOT( d, void finished() )
Q_PRIVATE_SLOT( d, void playOrPause() )
Q_PRIVATE_SLOT( d, void setPosterImage( const QImage& ) )
Q_PRIVATE_SLOT( d, void stateChanged( Phonon::State, Phonon::State ) )
// private storage
class Private;