Fix wrong interpretation of autoplay flag

BUGS: 436709
This commit is contained in:
Cimbali 2023-02-15 23:32:49 +00:00 committed by Albert Astals Cid
parent 5bb79f2cfd
commit a33e499b40
4 changed files with 33 additions and 1 deletions

View File

@ -30,6 +30,7 @@ public:
, m_tmp(nullptr)
, m_showControls(false)
, m_autoPlay(false)
, m_startPaused(false)
, m_showPosterImage(false)
{
}
@ -43,6 +44,7 @@ public:
QImage m_posterImage;
bool m_showControls : 1;
bool m_autoPlay : 1;
bool m_startPaused : 1;
bool m_showPosterImage : 1;
};
@ -145,6 +147,16 @@ bool Movie::autoPlay() const
return d->m_autoPlay;
}
void Movie::setStartPaused(bool startPaused)
{
d->m_startPaused = startPaused;
}
bool Movie::startPaused() const
{
return d->m_startPaused;
}
void Movie::setShowPosterImage(bool show)
{
d->m_showPosterImage = show;

View File

@ -117,6 +117,16 @@ public:
*/
bool autoPlay() const;
/**
* Sets whether to start the movie in paused mode
*/
void setStartPaused(bool startPaused);
/**
* Whether to start the movie in paused mode
*/
bool startPaused() const;
/**
* Sets whether to show a poster image.
*

View File

@ -218,6 +218,7 @@ Okular::Movie *createMovieFromPopplerMovie(const Poppler::MovieObject *popplerMo
movie->setShowControls(popplerMovie->showControls());
movie->setPlayMode((Okular::Movie::PlayMode)popplerMovie->playMode());
movie->setAutoPlay(false); // will be triggered by external MovieAnnotation
movie->setStartPaused(false);
movie->setShowPosterImage(popplerMovie->showPosterImage());
movie->setPosterImage(popplerMovie->posterImage());
return movie;
@ -240,7 +241,13 @@ Okular::Movie *createMovieFromPopplerScreen(const Poppler::LinkRendition *popple
movie->setPlayMode(Okular::Movie::PlayLimited);
movie->setPlayRepetitions(rendition->repeatCount());
}
movie->setAutoPlay(rendition->autoPlay());
/**
* Warning: Confusing flag name from PDF spec. Described as:
* > If true, the media should automatically play when activated.
* > If false, the media should be initially paused when activated
* To set autoplay, page actions are used.
*/
movie->setStartPaused(!rendition->autoPlay());
return movie;
}

View File

@ -325,6 +325,9 @@ void VideoWidget::pageEntered()
if (d->movie->autoPlay()) {
show();
QMetaObject::invokeMethod(this, "play", Qt::QueuedConnection);
if (d->movie->startPaused()) {
QMetaObject::invokeMethod(this, "pause", Qt::QueuedConnection);
}
}
}