How to disconnect AVPlayer from AVPlayerItem?

I want to reuse AVPlayerItem, but keep getting this error:

An AVPlayerItem cannot be associated with more than one instance of AVPlayer

Before trying to reuse it, I destroy the previous AVPlayer as follows:

[self.player pause];
[self.player replaceCurrentItemWithPlayerItem:nil];
self.player = nil;

why is AVPlayerItem still connected and how to disable it?

Here is a Gist with full reproduction of the problem (only 50 lines by the way): https://gist.github.com/sbiermanlytle/14a6faab515f7691b810789086ae9e50

You can run it by creating a new Single View application and displacing the ViewController implementation with this code.

0
source share
1 answer

AVPlayerItems. , , , , , NULL, item NULL..

. URL-, AVAsset ( ...) , , PlayerItem, .

AVPlayerItem* newPlayerItem = [AVPlayerItem playerItemWithAsset:playerItem.asset];

. - "" , . .

+2

Source: https://habr.com/ru/post/1618040/


All Articles