MPMoviewPlayer错误[回放]❗️无法对任何项目进行排队

时间:2017-06-12 11:40:21

标签: ios objective-c xcode8 mpmovieplayercontroller ios10.3

使用 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之后受到尊重。还有其他选择吗?

1 个答案:

答案 0 :(得分:0)

评论movieSourceType对我有用:

//self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;