Привет всем, у меня странное поведение с MPMoviePlayerController
время, когда я играю видео, оно работает ... вечера нет!
как сказано здесь MPMoviePlayerController будет проигрываться один раз, а затем выдавать ошибку проблема может быть в URL, но я не могу найти решение ..
Вот мой код
NSURL *myUrl = [[NSURL alloc] initWithString:CDNRequest];
moviecontroller = [[MMRMovieViewController alloc] initWithContentURL:myUrl];
[[moviecontroller moviePlayer] setScalingMode:MPMovieScalingModeAspectFit];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification object:[moviecontroller moviePlayer]];
[self moviecontroller];
MMRMovieViewController - это контроллер представления, который просто расширяет MPMoviePlayerViewController.
а вот и метод playFinished
- (void)playbackFinished:(NSNotification*)notification {
MPMoviePlayerController *moviePlayer = [notification object];
NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
switch ([reason intValue]) {
case MPMovieFinishReasonPlaybackEnded:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"playback ended");
break;
case MPMovieFinishReasonPlaybackError:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"playback error");
NSError* error = [[notification userInfo] valueForKey:@"error"];
NSLog(@"error=%@", error);
break;
case MPMovieFinishReasonUserExited:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"user exited");
break;
default:
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
break;
}
if (moviePlayer == TRUE) {
[moviePlayer setFullscreen:NO animated:YES];
}
[moviePlayer stop];
[moviePlayer removeFromSuperview];
moviePlayer = nil;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
В журнале ошибок указано: «rror =» Error Domain = MediaPlayerErrorDomain Code = -12847 \ "Этот формат фильма не поддерживается. \" UserInfo = 0x5b60030 {NSLocalizedDescription = Этот формат фильма не поддерживается.} "
Но иногда это идет! так что это не может быть причиной!
Любая помощь приветствуется!
Спасибо!