ios – 崩溃 – [AVPlayerItem _attachToPlayer:] AVPlayerItem不能与多个AVPlayer实例相关联

我遇到了大约10%的用户崩溃,但我无法再现它,并且不清楚这一切发生.

Crashlytics报道了大约一半的应用程序不重要的崩溃用户,即做背景音乐或AirPlay.应用程序播放HLS视频流,并在后台切换到仅音频版本.

任何想法有什么问题,或为什么会有多个AVPlayer实例从我的单身玩家类?

谢谢!

Exception Type:
NSInvalidArgumentException
Reason:
An AVPlayerItem cannot be associated with more than one instance of AVPlayer
Fatal Exception
Latest Crash: 4/06/2013 at 8:48:46 UTC+0200
0   CoreFoundation  __exceptionPreprocess + 162
1   libobjc.A.dylib objc_exception_throw + 30
2   AVFoundation    -[AVPlayerItem _attachToPlayer:] + 188
3   AVFoundation    -[AVPlayer _attachItem:andPerformOperation:withObject:] + 336
4   AVFoundation    -[AVPlayer _insertItem:afterItem:] + 26
5   AVFoundation    -[AVQueuePlayer insertItem:afterItem:] + 136
6   MediaPlayer __block_global_4 + 520
7
...
libdispatch.dylib   _dispatch_call_block_and_release + 10
14

解决方法

似乎通过在设置新的URL之前明确地停止播放来解决.
[moviePlayer stop];
moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[moviePlayer setContentURL:[NSURL URLWithString:[videos objectForKey:quality]]];

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...