diff options
Diffstat (limited to 'src')
4 files changed, 39 insertions, 6 deletions
diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index 0666ab4fa..aa77a5177 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -69,6 +69,7 @@ QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *sessio , m_bufferProgress(-1) , m_seekToStartPending(false) , m_pendingSeekPosition(-1) + , m_setMediaPending(false) , m_stream(0) , m_fifoNotifier(0) , m_fifoCanWrite(false) @@ -238,6 +239,12 @@ void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState) return; pushState(); + + if (m_setMediaPending) { + m_mediaStatus = QMediaPlayer::LoadingMedia; + setMedia(m_currentResource, m_stream); + } + #ifdef Q_WS_MAEMO_6 //this is a work around for the gstreamer bug, //should be remove once it get fixed @@ -246,11 +253,6 @@ void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState) } #endif - if (m_mediaStatus == QMediaPlayer::EndOfMedia) { - m_mediaStatus = QMediaPlayer::BufferedMedia; - m_seekToStartPending = true; - } - if (!m_resources->isGranted()) m_resources->acquire(); @@ -356,6 +358,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * QMediaContent oldMedia = m_currentResource; m_pendingSeekPosition = -1; m_session->showPrerollFrames(false); // do not show prerolled frames until pause() or play() explicitly called + m_setMediaPending = false; if (!content.isNull() || stream) { if (!m_resources->isGranted()) @@ -552,7 +555,14 @@ void QGstreamerPlayerControl::processEOS() pushState(); m_mediaStatus = QMediaPlayer::EndOfMedia; emit positionChanged(position()); - stop(); + m_session->endOfMediaReset(); + m_setMediaPending = true; + + if (m_state != QMediaPlayer::StoppedState) { + m_state = QMediaPlayer::StoppedState; + m_session->showPrerollFrames(false); // stop showing prerolled frames in stop state + } + popAndNotifyState(); } diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.h b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.h index a9b1c8487..4511d7edf 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.h +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.h @@ -144,6 +144,7 @@ private: int m_bufferProgress; bool m_seekToStartPending; qint64 m_pendingSeekPosition; + bool m_setMediaPending; QMediaContent m_currentResource; QIODevice *m_stream; QSocketNotifier *m_fifoNotifier; diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp index 3fa93f02d..c7e38a7c5 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp @@ -1772,6 +1772,26 @@ gboolean QGstreamerPlayerSession::padAudioBufferProbe(GstPad *pad, GstBuffer *bu return TRUE; } +// This function is similar to stop(), +// but does not set m_everPlayed, m_lastPosition, +// and setSeekable() values. +void QGstreamerPlayerSession::endOfMediaReset() +{ + if (m_renderer) + m_renderer->stopRenderer(); + + flushVideoProbes(); + gst_element_set_state(m_playbin, GST_STATE_NULL); + + QMediaPlayer::State oldState = m_state; + m_pendingState = m_state = QMediaPlayer::StoppedState; + + finishVideoOutputChange(); + + if (oldState != m_state) + emit stateChanged(m_state); +} + void QGstreamerPlayerSession::removeVideoBufferProbe() { if (m_videoBufferProbeId == -1) diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h index 044053c96..4bda52d85 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h @@ -131,6 +131,8 @@ public: void removeProbe(QGstreamerAudioProbeControl* probe); static gboolean padAudioBufferProbe(GstPad *pad, GstBuffer *buffer, gpointer user_data); + void endOfMediaReset(); + public slots: void loadFromUri(const QNetworkRequest &url); void loadFromStream(const QNetworkRequest &url, QIODevice *stream); |