Fix a playback bug for mediaplayer windows media foundation backend
authorLing Hu <ling.hu@nokia.com>
Mon, 15 Aug 2011 01:17:23 +0000 (11:17 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 26 Sep 2011 05:22:52 +0000 (07:22 +0200)
Task-number:QTMOBILITY-1606

Reviewed-by:Jonas Rabbe
(cherry picked from commit d5426bf52e19c9c6a52837b423f48024979ea076)

Change-Id: Ie7c1c90a8f5a64e77c435ffc1917d8f9638dfff3
Reviewed-on: http://codereview.qt-project.org/5499
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
src/plugins/wmf/player/mfplayercontrol.cpp
src/plugins/wmf/player/mfplayersession.cpp
src/plugins/wmf/player/mfplayersession.h

index cb76a03..e3a3d80 100644 (file)
@@ -72,7 +72,12 @@ MFPlayerControl::~MFPlayerControl()
 
 void MFPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream)
 {
-    stop();
+    if (m_state != QMediaPlayer::StoppedState) {
+        changeState(QMediaPlayer::StoppedState);
+        m_session->stop(true);
+        refreshState();
+    }
+
     m_media = media;
     m_stream = stream;
     resetAudioVideoAvailable();
index 42b4f60..afe91da 100644 (file)
@@ -681,12 +681,12 @@ IMFTopologyNode* MFPlayerSession::addOutputNode(IMFStreamDescriptor *streamDesc,
     return NULL;
 }
 
-void MFPlayerSession::stop()
+void MFPlayerSession::stop(bool immediate)
 {
 #ifdef DEBUG_MEDIAFOUNDATION
     qDebug() << "stop";
 #endif
-    if (m_pendingState != NoPending) {
+    if (!immediate && m_pendingState != NoPending) {
         m_request.setCommand(CmdStop);
     } else {
         if (m_state.command == CmdStop)
@@ -1186,7 +1186,11 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
         if (m_status != QMediaPlayer::EndOfMedia) {
             m_varStart.vt = VT_I8;
             m_varStart.hVal.QuadPart = 0;
-            changeStatus(QMediaPlayer::LoadedMedia);
+
+            //only change to loadedMedia when not loading a new media source
+            if (m_status != QMediaPlayer::LoadingMedia) {
+                changeStatus(QMediaPlayer::LoadedMedia);
+            }
         }
         updatePendingCommands(CmdStop);
         break;
index 933c865..169a404 100644 (file)
@@ -94,7 +94,7 @@ public:
     }
 
     void load(const QMediaContent &media, QIODevice *stream);
-    void stop();
+    void stop(bool immediate = false);
     void start();
     void pause();