I'm trying to play video with the following code:
UIGraphicsBeginImageContext(CGSizeMake(1,1));
self.player = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://www.blablabla.org/app/video/v5_seq8_v2_360p.mp4"]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.player.moviePlayer];
[self presentMoviePlayerViewControllerAnimated:self.player];
UIGraphicsEndImageContext();
[self.player.moviePlayer prepareToPlay];
[self.player.moviePlayer play];
The sel.player
closes and didFinishPlayback:
method is called instantly. I retrieve the error from the notification like this:
NSLog(@"Error %@", notification.userInfo[@"error"]);
and it looks like the following:
Domain=MediaPlayerErrorDomain Code=-11850 "Operation Stopped"
but when i open the url in a browser then the video starts playing without any problems. What can be the cause of this error? Thanks