2

After upgrading to XCode 8.3.3 with iOS SDK 10.3.x I am facing below error :

[Playback] ❗️Playback failed with error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x17425a8b0 {Error Domain=NSOSStatusErrorDomain Code=1885696621 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (1885696621), NSLocalizedDescription=The operation could not be completed}, not resolving (canResolve: YES, errorResolver: (null))

[Playback] ❗️Failed to queue any items ...

Here is my code :

//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];

Implementing selectors :

- (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];
}

EDIT 1 : I am fully aware of MPMoviePlayer is depectated after iOS 9.0. Is there any other option ?

byJeevan
  • 3,728
  • 3
  • 37
  • 60

1 Answers1

0

Commenting movieSourceType worked for me:

//self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
Vishwas Singh
  • 1,497
  • 1
  • 18
  • 16