summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@qt.io>2016-08-01 16:14:46 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-08-12 12:00:13 +0000
commitcf439602fd6a9d2a62924087499cbd621fbf7585 (patch)
treec93771c5252915b35f575d4e42d7904655d746df
parent124987e4bc4b39cae7074eb75e2bb3e3436aded0 (diff)
Fix playing a playlist containing an invalid media as first item
When a playlist contains an invalid media, QMediaPlayer normally continues to the next media. If an invalid media was first in the list, the backend would never go into PlayingState, which would then cause the media player to never start the next item in the list (thinking it's stopped). We now always transition to PlayingState when starting playback of a playlist, regardless of the backend going into that state or not. Change-Id: I4227f937e7a619afbd8adbe2fccedfa5d43ad89a Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r--src/multimedia/playback/qmediaplayer.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp
index c1636e8e..e6e4c7c1 100644
--- a/src/multimedia/playback/qmediaplayer.cpp
+++ b/src/multimedia/playback/qmediaplayer.cpp
@@ -853,17 +853,19 @@ void QMediaPlayer::play()
}
//if playlist control is available, the service should advance itself
- if (d->rootMedia.playlist() && d->rootMedia.playlist()->currentIndex() == -1 && !d->rootMedia.playlist()->isEmpty()) {
-
+ if (d->rootMedia.playlist() && !d->rootMedia.playlist()->isEmpty()) {
// switch to playing state
if (d->state != QMediaPlayer::PlayingState)
d->_q_stateChanged(QMediaPlayer::PlayingState);
- if (d->playlist != d->rootMedia.playlist())
- d->setPlaylist(d->rootMedia.playlist());
- Q_ASSERT(d->playlist == d->rootMedia.playlist());
- emit currentMediaChanged(d->rootMedia);
- d->playlist->setCurrentIndex(0);
+ if (d->rootMedia.playlist()->currentIndex() == -1) {
+ if (d->playlist != d->rootMedia.playlist())
+ d->setPlaylist(d->rootMedia.playlist());
+ Q_ASSERT(d->playlist == d->rootMedia.playlist());
+
+ emit currentMediaChanged(d->rootMedia);
+ d->playlist->setCurrentIndex(0);
+ }
}
// Reset error conditions