diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-24 00:51:17 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-24 00:51:17 (GMT) |
commit | 8da6db0d98f3ade7440fa0434fc500517f21625c (patch) | |
tree | 680377d63816729df13b1e15e119280db900e729 /src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp | |
parent | 9ea81cbc63db063cd30797fd265a9002430ebd2f (diff) | |
parent | 00721d83b20a5e1e66c46cefe98311ee2882b198 (diff) | |
download | Qt-8da6db0d98f3ade7440fa0434fc500517f21625c.zip Qt-8da6db0d98f3ade7440fa0434fc500517f21625c.tar.gz Qt-8da6db0d98f3ade7440fa0434fc500517f21625c.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging: (27 commits)
Remove trace code from directshowaudioendpointcontrol.h.
New configure.exe binary
Add support for MSBuild, which is the project format for MSVC 2010
Only add qvideowidget test once.
Multimedia causes build failure when Qt is configured with -embedded
Player demo: load not only local files but playlists and urls passed as
Gstreamer media backend: preserve playback rate after seeks and media
QT7 mediaservice; fix leaking strings.
Fixed Qt build with mediaservices disabled.
Multimedia tests; fix for missing dependency
Disabled QMediaPlayer states debug output.
Fixed typo in QMediaPlayer::play() error reporting
Fixed QVideoWidget test, waiting for video surface painted.
Tests; Fix media tests, make sure they are using mediaservies.
Fix warning about illegal empty declaration.
Three fixes from Shane after QtMultimedia was split into two dlls.
Fix compile errors in Direct Show media service.
Add EXPORT defines for QtMediaServices library.
Fixed configure check for gstreamer.
WebKit; build with change to mediaservices.
...
Diffstat (limited to 'src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp')
-rw-r--r-- | src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp | 98 |
1 files changed, 74 insertions, 24 deletions
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index e646693..6dd914a 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -62,6 +62,7 @@ QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *sessio , m_state(QMediaPlayer::StoppedState) , m_mediaStatus(QMediaPlayer::NoMedia) , m_bufferProgress(-1) + , m_seekToStartPending(false) , m_stream(0) , m_fifoNotifier(0) , m_fifoCanWrite(false) @@ -107,7 +108,7 @@ QGstreamerPlayerControl::~QGstreamerPlayerControl() qint64 QGstreamerPlayerControl::position() const { - return m_session->position(); + return m_seekToStartPending ? 0 : m_session->position(); } qint64 QGstreamerPlayerControl::duration() const @@ -170,37 +171,77 @@ void QGstreamerPlayerControl::setPlaybackRate(qreal rate) void QGstreamerPlayerControl::setPosition(qint64 pos) { - m_session->seek(pos); + if (m_mediaStatus == QMediaPlayer::EndOfMedia) { + m_mediaStatus = QMediaPlayer::LoadedMedia; + emit mediaStatusChanged(m_mediaStatus); + } + + if (m_session->seek(pos)) + m_seekToStartPending = false; } void QGstreamerPlayerControl::play() { - if (m_session->play()) { - if (m_state != QMediaPlayer::PlayingState) - emit stateChanged(m_state = QMediaPlayer::PlayingState); - } + playOrPause(QMediaPlayer::PlayingState); } void QGstreamerPlayerControl::pause() { - if (m_session->pause()) { - if (m_state != QMediaPlayer::PausedState) - emit stateChanged(m_state = QMediaPlayer::PausedState); - } + playOrPause(QMediaPlayer::PausedState); } -void QGstreamerPlayerControl::stop() +void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState) { - if (m_state != QMediaPlayer::StoppedState) { + QMediaPlayer::State oldState = m_state; + QMediaPlayer::MediaStatus oldMediaStatus = m_mediaStatus; + + if (m_mediaStatus == QMediaPlayer::EndOfMedia) + m_mediaStatus = QMediaPlayer::BufferedMedia; + + if (m_seekToStartPending) { m_session->pause(); if (!m_session->seek(0)) { m_bufferProgress = -1; m_session->stop(); - m_session->pause(); + m_mediaStatus = QMediaPlayer::LoadingMedia; } + m_seekToStartPending = false; + } + + bool ok = false; + if (newState == QMediaPlayer::PlayingState) + ok = m_session->play(); + else + ok = m_session->pause(); + + if (!ok) + return; + + m_state = newState; + + if (m_mediaStatus == QMediaPlayer::EndOfMedia || m_mediaStatus == QMediaPlayer::LoadedMedia) { + if (m_bufferProgress == -1 || m_bufferProgress == 100) + m_mediaStatus = QMediaPlayer::BufferedMedia; + else + m_mediaStatus = QMediaPlayer::BufferingMedia; + } + + if (m_state != oldState) + emit stateChanged(m_state); + if (m_mediaStatus != oldMediaStatus) + emit mediaStatusChanged(m_mediaStatus); + +} + +void QGstreamerPlayerControl::stop() +{ + if (m_state != QMediaPlayer::StoppedState) { + m_state = QMediaPlayer::StoppedState; + m_session->pause(); + m_seekToStartPending = true; + updateState(m_session->state()); emit positionChanged(0); - if (m_state != QMediaPlayer::StoppedState) - emit stateChanged(m_state = QMediaPlayer::StoppedState); + emit stateChanged(m_state); } } @@ -244,6 +285,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * m_currentResource = content; m_stream = stream; + m_seekToStartPending = false; QUrl url; @@ -255,7 +297,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * url = content.canonicalUrl(); } - m_session->load(url); + m_session->load(url); if (m_fifoFd[1] >= 0) { m_fifoCanWrite = true; @@ -296,24 +338,34 @@ bool QGstreamerPlayerControl::isVideoAvailable() const void QGstreamerPlayerControl::updateState(QMediaPlayer::State state) { QMediaPlayer::MediaStatus oldStatus = m_mediaStatus; + QMediaPlayer::State oldState = m_state; switch (state) { case QMediaPlayer::StoppedState: - if (m_state != QMediaPlayer::StoppedState) - emit stateChanged(m_state = QMediaPlayer::StoppedState); + m_state = QMediaPlayer::StoppedState; + if (m_currentResource.isNull()) + m_mediaStatus = QMediaPlayer::NoMedia; + else + m_mediaStatus = QMediaPlayer::LoadingMedia; break; case QMediaPlayer::PlayingState: case QMediaPlayer::PausedState: - if (m_state == QMediaPlayer::StoppedState) + if (m_state == QMediaPlayer::StoppedState) { m_mediaStatus = QMediaPlayer::LoadedMedia; - else { - if (m_bufferProgress == -1) + } else { + if (m_bufferProgress == -1 || m_bufferProgress == 100) m_mediaStatus = QMediaPlayer::BufferedMedia; } break; } + //EndOfMedia status should be kept, until reset by pause, play or setMedia + if (oldStatus == QMediaPlayer::EndOfMedia) + m_mediaStatus = QMediaPlayer::EndOfMedia; + + if (m_state != oldState) + emit stateChanged(m_state); if (m_mediaStatus != oldStatus) emit mediaStatusChanged(m_mediaStatus); } @@ -321,9 +373,7 @@ void QGstreamerPlayerControl::updateState(QMediaPlayer::State state) void QGstreamerPlayerControl::processEOS() { m_mediaStatus = QMediaPlayer::EndOfMedia; - m_state = QMediaPlayer::StoppedState; - - emit stateChanged(m_state); + stop(); emit mediaStatusChanged(m_mediaStatus); } |