From 70ad769934d9c82e1d1dd11e96386ce59db7631e Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Mon, 20 May 2019 15:47:48 +0200 Subject: GStreamer: Don't seek to the beginning when playing is requested We promised to not provide any video frames before pause() or play() is called. Regardless the media is loaded or not. It should work like following: setMedia(new) // ... // no video frames returned yet pause() // prerolled frame should be shown To implement this, i.e. showing the prerolled frame after pause, we do seeking to the beginning. But it is totally not necessarily when play() is requested, since here is new media and playback will start from the beginning anyway. This also produces a hang/stuck on some embedded systems with custom pipelines or playing from qrc. So decided to show prerolled frame and this means to seek to the beginning only when pause() is called. Task-number: QTBUG-65399 Change-Id: I9b3dc632fa0df4a1115d852c2d480fd5c7fd9ee5 Reviewed-by: Timur Pocheptsov --- src/gsttools/qgstreamerplayercontrol.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gsttools') diff --git a/src/gsttools/qgstreamerplayercontrol.cpp b/src/gsttools/qgstreamerplayercontrol.cpp index 73f43f0b9..d49b09af4 100644 --- a/src/gsttools/qgstreamerplayercontrol.cpp +++ b/src/gsttools/qgstreamerplayercontrol.cpp @@ -225,6 +225,10 @@ void QGstreamerPlayerControl::pause() qDebug() << Q_FUNC_INFO; #endif m_userRequestedState = QMediaPlayer::PausedState; + // If the playback has not been started yet but pause is requested. + // Seek to the beginning to show first frame. + if (m_pendingSeekPosition == -1 && m_session->position() == 0) + m_pendingSeekPosition = 0; playOrPause(QMediaPlayer::PausedState); } @@ -354,7 +358,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * m_currentState = QMediaPlayer::StoppedState; QMediaContent oldMedia = m_currentResource; - m_pendingSeekPosition = 0; + m_pendingSeekPosition = -1; m_session->showPrerollFrames(false); // do not show prerolled frames until pause() or play() explicitly called m_setMediaPending = false; -- cgit v1.2.3