diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 5d078b0..bbbe4d9 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -114,6 +114,7 @@ MediaPlayerPrivateQt::MediaPlayerPrivateQt(MediaPlayer* player) , m_preload(MediaPlayer::Auto) , m_bytesLoadedAtLastDidLoadingProgress(0) , m_suppressNextPlaybackChanged(false) + , m_prerolling(false) { m_mediaPlayer->setVideoOutput(this); @@ -244,10 +245,8 @@ void MediaPlayerPrivateQt::commitLoad(const String& url) // Setting a media source will start loading the media, but we need // to pre-roll as well to get video size-hints and buffer-status - if (m_webCorePlayer->paused()) - m_mediaPlayer->pause(); - else - m_mediaPlayer->play(); + m_prerolling = true; + m_mediaPlayer->play(); } void MediaPlayerPrivateQt::resumeLoad() @@ -284,16 +283,18 @@ void MediaPlayerPrivateQt::pause() bool MediaPlayerPrivateQt::paused() const { - return (m_mediaPlayer->state() != QMediaPlayer::PlayingState); + return (m_prerolling || m_mediaPlayer->state() != QMediaPlayer::PlayingState); } void MediaPlayerPrivateQt::seek(float position) { - if (!m_mediaPlayer->isSeekable()) - return; - - if (m_mediaPlayerControl && !m_mediaPlayerControl->availablePlaybackRanges().contains(position * 1000)) + if (!m_mediaPlayer->isSeekable()) { + // Even if seeking can't be performed, we need to report that the + // position changed in order for the video element to continue + // playing. + m_webCorePlayer->timeChanged(); return; + } m_isSeeking = true; m_mediaPlayer->setPosition(static_cast(position * 1000)); @@ -411,8 +412,16 @@ void MediaPlayerPrivateQt::setVisible(bool) { } -void MediaPlayerPrivateQt::mediaStatusChanged(QMediaPlayer::MediaStatus) +void MediaPlayerPrivateQt::mediaStatusChanged(QMediaPlayer::MediaStatus status) { + // Pre-roll done + if (m_prerolling && (status == QMediaPlayer::BufferingMedia || status == QMediaPlayer::BufferedMedia)) { + // Don't send PlaybackChanged notification for pre-roll. + m_suppressNextPlaybackChanged = true; + m_prerolling = false; + m_mediaPlayer->pause(); + } + updateStates(); } diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h index 7e388c4..b68b31f 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h @@ -161,6 +161,7 @@ private: bool m_delayingLoad; String m_mediaUrl; bool m_suppressNextPlaybackChanged; + bool m_prerolling; }; }