From 0a6f22dbbc3f36b82190b1dc52ecee082c8b90bc Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Mon, 7 Oct 2019 14:31:56 +0200 Subject: 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 --- .../avfoundation/mediaplayer/avfmediaplayersession.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') 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(m_observer) player] setRate:m_rate]; + } + + if (m_mediaStatus != status) + Q_EMIT mediaStatusChanged(m_mediaStatus = status); + m_bufferStatus = bufferStatus; Q_EMIT bufferStatusChanged(bufferStatus); } -- cgit v1.2.1