summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@qt.io>2016-07-28 11:53:40 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-08-12 12:00:46 +0000
commitc30eeb5b7486caa31cdb0f9279de2f78fed89c54 (patch)
tree43bd9d8e1a205927de8d0c74f2e3713a30f28a37
parentb69862eb2ac587d75580d80b293042e9fdb3bb1c (diff)
WinRT: emit mediaStatus changes before state changes
This makes sure all mediaStatus changes are emitted, even when some action is done on the media player as a result of a state change. Also, when both mediaStatus and state are changed at the same time, make sure both variables are updated before sending the corresponding signals. Task-number: QTBUG-49578 Change-Id: I8eed6692503bba1540070f6435b7ea1f5e25c023 Reviewed-by: Andrew Knight <andrew.knight@intopalo.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Christian Stromme <christian.stromme@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--src/plugins/winrt/qwinrtmediaplayercontrol.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp
index d00788e6..05dcc29f 100644
--- a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp
+++ b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp
@@ -263,18 +263,19 @@ public:
break;
}
- if (d->state != newState) {
- d->state = newState;
- emit q->stateChanged(d->state);
- }
-
if (d->videoRenderer)
d->videoRenderer->setActive(d->state == QMediaPlayer::PlayingState);
- if (d->mediaStatus != newStatus) {
- d->mediaStatus = newStatus;
+ const QMediaPlayer::MediaStatus oldMediaStatus = d->mediaStatus;
+ const QMediaPlayer::State oldState = d->state;
+ d->mediaStatus = newStatus;
+ d->state = newState;
+
+ if (d->mediaStatus != oldMediaStatus)
emit q->mediaStatusChanged(d->mediaStatus);
- }
+
+ if (d->state != oldState)
+ emit q->stateChanged(d->state);
return S_OK;
}
@@ -855,17 +856,22 @@ void QWinRTMediaPlayerControl::stop()
{
Q_D(QWinRTMediaPlayerControl);
- if (d->state != QMediaPlayer::StoppedState) {
- d->state = QMediaPlayer::StoppedState;
- emit stateChanged(d->state);
- }
+ const QMediaPlayer::MediaStatus oldMediaStatus = d->mediaStatus;
+ const QMediaPlayer::State oldState = d->state;
+
+ d->state = QMediaPlayer::StoppedState;
if (d->mediaStatus == QMediaPlayer::BufferedMedia
|| d->mediaStatus == QMediaPlayer::BufferingMedia) {
d->mediaStatus = QMediaPlayer::LoadedMedia;
- emit mediaStatusChanged(d->mediaStatus);
}
+ if (d->mediaStatus != oldMediaStatus)
+ emit mediaStatusChanged(d->mediaStatus);
+
+ if (d->state != oldState)
+ emit stateChanged(d->state);
+
if (d->media.isNull() && d->stream.isNull())
return;