diff options
author | Yoann Lopes <yoann.lopes@qt.io> | 2016-07-28 11:53:40 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@qt.io> | 2016-08-12 12:00:46 +0000 |
commit | c30eeb5b7486caa31cdb0f9279de2f78fed89c54 (patch) | |
tree | 43bd9d8e1a205927de8d0c74f2e3713a30f28a37 | |
parent | b69862eb2ac587d75580d80b293042e9fdb3bb1c (diff) | |
download | qtmultimedia-c30eeb5b7486caa31cdb0f9279de2f78fed89c54.tar.gz |
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.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp index d00788e64..05dcc29f4 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; |