diff options
author | Michael BrĂ¼ning <michael.bruning@digia.com> | 2014-10-20 11:40:13 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2014-10-30 10:47:57 +0100 |
commit | 4ab0f495a26ae18cb7be7a4ddb4c411eba06b398 (patch) | |
tree | 3f6c54c9778b838efa11a0b2e5d715dca6441343 | |
parent | d3c1f581037efde000b0716b55c8ca830bae0482 (diff) | |
download | qtwebkit-4ab0f495a26ae18cb7be7a4ddb4c411eba06b398.tar.gz |
Fix preloading of video when using QtMultimedia backend.
Based on a patch by Yoann Lopes (yoann.lopes@theqtcompany.com).
Task-number: QTBUG-37381
Change-Id: I8647c578399a592f8feef0d4028187afd3726b2d
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
-rw-r--r-- | Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp | 19 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h | 1 |
2 files changed, 15 insertions, 5 deletions
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 5d078b0ba..b2c8d485d 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); @@ -245,9 +246,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() @@ -272,6 +272,7 @@ void MediaPlayerPrivateQt::prepareToPlay() void MediaPlayerPrivateQt::play() { + m_prerolling = false; if (m_mediaPlayer->state() != QMediaPlayer::PlayingState) m_mediaPlayer->play(); } @@ -284,7 +285,7 @@ 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) @@ -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 7e388c408..b68b31fd6 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; }; } |