diff options
author | Doris Verria <doris.verria@qt.io> | 2021-09-11 23:04:54 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-13 12:09:37 +0000 |
commit | d96f082ce7cf882a3a8839e5bc1637e1a5880c31 (patch) | |
tree | 2c917d06d481f1caa68d73a49bf365c8b42fc2ba /src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm | |
parent | 21475678b7532e30979df28576f32584b2d21bef (diff) |
AVFVideoRenderer: Properly update video output when changing media
When changing the video source of the AVFMediaPlayer, the video frame
was not updated and displayed the last frame of the previous video.
To fix, before setting a new CALayer to the renderer, make sure to
remove the video output and subtitle output from the previous
AVPlayerItem and add them to the updated one.
Also, clear the last video frame from the video output by setting a
null QVideoFrame() to the sink whenever the mediaplayer stops or
reaches end of stream.
Fixes: QTBUG-96368
Change-Id: I74ed056c1ece0db319e857b89eaf5e5168a972a1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 59a32742d66a1fe17320acd133922c105ec211f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm')
-rw-r--r-- | src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm index c0904fddd..2cd61a42e 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm @@ -183,6 +183,8 @@ static void *AVFMediaPlayerObserverCurrentItemDurationObservationContext = &AVFM [m_player release]; m_player = 0; } + if (m_playerLayer) + m_playerLayer.player = nil; #if defined(Q_OS_IOS) [[AVAudioSession sharedInstance] setActive:NO error:nil]; #endif @@ -874,6 +876,9 @@ void AVFMediaPlayer::stop() [[static_cast<AVFMediaPlayerObserver*>(m_observer) player] pause]; setPosition(0); + if (m_videoOutput) + m_videoOutput->setLayer(nullptr); + if (m_mediaStatus == QMediaPlayer::BufferedMedia) Q_EMIT mediaStatusChanged((m_mediaStatus = QMediaPlayer::LoadedMedia)); @@ -928,6 +933,9 @@ void AVFMediaPlayer::processEOS() m_mediaStatus = QMediaPlayer::EndOfMedia; m_state = QMediaPlayer::StoppedState; + if (m_videoOutput) + m_videoOutput->setLayer(nullptr); + Q_EMIT mediaStatusChanged(m_mediaStatus); Q_EMIT stateChanged(m_state); } |