使用 iOS SDK 10.3.x 升级到 XCode 8.3.3 后,我面临以下错误:
[回放]❗️Playback失败并显示错误:错误Domain = AVFoundationErrorDomain Code = -11800"操作无法完成" UserInfo = {NSUnderlyingError = 0x17425a8b0 {Error Domain = NSOSStatusErrorDomain Code = 1885696621"(null)"},NSLocalizedFailureReason =发生未知错误(1885696621),NSLocalizedDescription =操作无法完成},未解决( canResolve:YES,errorResolver:(null))
[回放]❗️无法排队任何物品......
这是我的代码:
//ViewDidLoad
NSString *videoFilePath = [videoPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
MPMoviePlayerController * moviePlayer = [[MPMoviePlayerController alloc] init];
NSURL *videoURL = [NSURL fileURLWithPath:videoFilePath];
[moviePlayer setContentURL:videoURL];
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
moviePlayer.fullscreen = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playMovie:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer];
实施选择器:
- (void)playMovie:(NSNotification *)notification {
MPMoviePlayerController *player = notification.object;
if (player.loadState & MPMovieLoadStatePlayable) {
[player play];
//Other lines
}
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[player stop];
[player.view removeFromSuperview];
}
编辑1:我完全了解MPMoviePlayer在iOS 9.0之后受到尊重。还有其他选择吗?
答案 0 :(得分:0)
评论movieSourceType对我有用:
//self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;