使用iOS SDK 10.3.x升级到XCode 8.3.3后,我面临以下错误:
[播放] ❗️播放失败并出现错误:Error Domain=AVFoundationErrorDomain Code=-11800 "操作无法完成" UserInfo={NSUnderlyingError=0x17425a8b0 {Error Domain=NSOSStatusErrorDomain Code=1885696621 "(null)"}, NSLocalizedFailureReason=An unknown发生错误(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 之后被怀疑。还有其他选择吗?