【发布时间】:2012-10-15 20:56:06
【问题描述】:
当我尝试播放任何视频时,我的 MPMoviePlayerController 崩溃了。
这只发生在模拟器上,在设备上可以正常工作。
错误如下:
2012-10-25 16:46:24.033 TheFasterChef[8529:14303] [MPAVController] Autoplay: Disabling autoplay for pause
2012-10-25 16:46:24.035 TheFasterChef[8529:14303] [MPAVController] Autoplay: Disabling autoplay
2012-10-25 16:46:24.172 TheFasterChef[8529:14303] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
2012-10-25 16:46:24.190 TheFasterChef[8529:14303] [MPAVController] Autoplay: Enabling autoplay
2012-10-25 16:46:24.227 TheFasterChef[8529:14303] [MPAVController] Autoplay: Likely to keep up or full buffer: 0
2012-10-25 16:46:24.227 TheFasterChef[8529:14303] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
2012-10-25 16:46:24.232 TheFasterChef[8529:14303] [MPAVController] Autoplay: Enabling autoplay
2012-10-25 16:46:24.238 TheFasterChef[8529:14303] [MPCloudAssetDownloadController] Prioritization requested for media item ID: 0
我的代码是调用MPMoviePlayerController的bog标准方法:
在 .h 文件中:
@property (retain) MPMoviePlayerController *videoPlayer;
在 .m 文件中:
NSBundle *appBundle = [NSBundle mainBundle];
//NSString *contentURLString = [appBundle pathForResource:videoIdentifier ofType:@"mp4"];
NSString *contentURLString = [appBundle pathForResource:@"test" ofType:@".mp4"];
NSURL *contentURL = [NSURL fileURLWithPath:contentURLString];
self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:contentURL];
[self.videoPlayer prepareToPlay];
[self.videoPlayer.view setFrame: self.view.bounds];
[self.view addSubview:self.videoPlayer.view];
[self.videoPlayer prepareToPlay];
[self.videoPlayer play];
我已经在不同的视图控制器中尝试了这个 sn-p 代码,但错误结果相同。
我在一个新项目中尝试过这个 sn-p 代码,它工作正常。
还有什么可能导致此错误?
here的答案没有为我解决。
【问题讨论】:
-
您的日志中没有
error- 一切正常。您是否在 Xcode 调试器中激活了异常断点?如果是这样,一旦停用该断点,应用程序是否也会崩溃? -
天哪,你是对的。我觉得自己像个娘们。在诉诸堆栈溢出之前,我不会透露我为此困惑了多久,但不用说,真诚地感谢 Till。
-
:D - 从现在开始我的荣幸和好运......
-
@Till 这是一个非常有用的提示。模拟器中使用的 Xcode 和 MPMoviePlayerController 之间存在某种不良交互。关闭异常断点可以修复它。你应该把你的评论变成一个实际的答案;我想赞成它!
-
同意马特,很乐意接受!
标签: ios xcode ios-simulator mpmovieplayercontroller