1

这是我的问题,我尝试使用MPMoviePlayerController播放流视频,所以我准备将MPMoviePlayerController's 视图放在我的自定义 viewController 中,将controlStyle属性设置为MPMovieControlStyleNone,并提供自定义播放器控制器,并在我的 init 方法中:

_moviePlayer = [[MPMoviePlayerController alloc] init];  
_moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  
_moviePlayer.shouldAutoplay = YES;  
_moviePlayer.scalingMode = MPMovieScalingModeAspectFit;  
_moviePlayer.controlStyle = MPMovieControlStyleNone;

并且我将自定义播放器控件放在 上moviePlayer,当我准备播放时,我从网络获取真实 URL 并让moviePlayer播放:

_moviePlayer.contentURL = [NSURL URLWithString:url];  
[_moviePlayer prepareToPlay];

然后我注册相关通知以报告发生了什么
我提供了简单的 seek 方法seek并调用了moviePlayerseek 方法,我发现当网络延迟很高时我尝试搜索,一段时间后,应用程序崩溃了。以及以下调用堆栈:

`0 CoreFoundation 0x381bd8a7 __exceptionPreprocess + 186  
1 libobjc.A.dylib 0x334ee259 objc_exception_throw + 32  
2 AVFoundation 0x37afb0dd -[AVPlayerItem _attachToPlayer:forImmediateEnqueueing:shouldAppendItem:] + 320   
3 AVFoundation 0x37af1edb -[AVPlayer _insertPlaybackItemOfItem:inPlayerQueueAfterPlaybackItemOfItem:] + 42  
4 AVFoundation 0x37af2c37 __block_global_0 + 1038  
5 libdispatch.dylib 0x34ae5c59 _dispatch_call_block_and_release + 12  
6 libdispatch.dylib 0x34ae7ee7 _dispatch_main_queue_callback_4CF$VARIANT$mp + 194
7 CoreFoundation  0x381902ad __CFRunLoopRun + 1268  
8   CoreFoundation  0x381134a5 CFRunLoopRunSpecific + 300  
9   CoreFoundation  0x3811336d CFRunLoopRunInMode + 104  
10  GraphicsServices0x365f6439 GSEventRunModal + 136  
11  UIKit 0x30fc4cd5 UIApplicationMain + 1080  
12  Player 0x000284dd main + 152  
13  Player 0x0001abb8 start + 40  
"Exception Name" = NSInvalidArgumentException  
"Exception Reason" = "An AVPlayerItem cannot be associated with more than one instance of AVPlayer`  

看到预期的原因,我想我可能会初始化 AVPlayer 的多个实例,但我只有一个 MPMoviePlayerController,任何人都可以为我指明方向吗?谢谢

4

1 回答 1

1

您没有显示任何代码,因此无法理解您的问题。问题是做错了什么,所以如果你需要帮助,你必须准确地展示你在做什么。

但是,请注意 Apple 可能已经在帮助您。您收到的错误消息非常明确:

"Exception Reason" = "一个 AVPlayerItem 不能与多个 AVPlayer 实例关联"

这可能是一个巨大的线索。考虑一下您可能如何违反该规则可能会很有用。

于 2013-04-07T04:37:25.387 回答