summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-10-07 14:31:56 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-10-08 09:47:59 +0200
commit0a6f22dbbc3f36b82190b1dc52ecee082c8b90bc (patch)
treea8448209b297690e7fa6ae6c265abebfb4426ca1 /src
parentd2475bdd4cbb9a70abf19db465ddbdbf29591568 (diff)
downloadqtmultimedia-0a6f22dbbc3f36b82190b1dc52ecee082c8b90bc.tar.gz
AVF: Emit StalledMedia when unbuffered and resume playback afterwards
If remote source is requested to play but there is a limitation in network bandwidth, StalledMedia status is never emitted, also the playback is not resumed after buffer gets full again. Based on AVPlayerItem.playbackLikelyToKeepUp introduced changing the media status and resuming the playback. Task-number: QTBUG-49806 Change-Id: If8aa10a1ea2cee2a40c679871b836d2dca622fcd Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
index 2309221c2..3b25a5801 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
@@ -922,6 +922,19 @@ void AVFMediaPlayerSession::processBufferStateChange(int bufferStatus)
if (bufferStatus == m_bufferStatus)
return;
+ auto status = m_mediaStatus;
+ // Buffered -> unbuffered.
+ if (!bufferStatus) {
+ status = QMediaPlayer::StalledMedia;
+ } else if (status == QMediaPlayer::StalledMedia) {
+ status = QMediaPlayer::BufferedMedia;
+ // Resume playback.
+ [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] setRate:m_rate];
+ }
+
+ if (m_mediaStatus != status)
+ Q_EMIT mediaStatusChanged(m_mediaStatus = status);
+
m_bufferStatus = bufferStatus;
Q_EMIT bufferStatusChanged(bufferStatus);
}