From 8ac4ea8582eed62332e3861240415c7d4fa6b140 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Sun, 5 Dec 2021 01:11:19 +0100 Subject: Remove the AVPlayerItemVideoOutput from player item when changing media MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When updating the player item of the AVPlayer, make sure to remove the video output (AVPlayerItemVideoOutput) from it. It will be added again to the updated player item on the next call to copyPixelBufferFromLayer. This fixes issues where the last frame of the previous video source was sometimes flashed before rendering the new one. Fixes: QTBUG-87000 Change-Id: Iec66f0e27efe621d1992a2a0f9f5060aa51f7076 Reviewed-by: Tor Arne Vestbø --- src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm') diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index ae2234764..9928c665b 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -168,6 +168,10 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext [[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemTimeJumpedNotification object:m_playerItem]; + for (AVPlayerItemOutput *output in m_playerItem.outputs) { + if ([output isKindOfClass:[AVPlayerItemVideoOutput class]]) + [m_playerItem removeOutput:output]; + } m_playerItem = 0; } if (m_player) { -- cgit v1.2.3