我尝试让MPMoviePlayerController工作,但有一个奇怪的问题。在播放时我点击完成按钮,似乎触发了无限的外观:
2012-02-13 15:18:04.395 iDomsPortalDev [7376:12203] playbackFinished。 原因:用户退出2012-02-13 15:18:04.395 iDomsPortalDev [7376:12203] playbackFinished。原因:用户已退出2012-02-13 15:18:04.395 iDomsPortalDev [7376:12203] playbackFinished。原因:用户退出
我在开始时使用以下通知:
- (void) showMoviePlayer {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enteredFullscreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
id appDelegate = (iDomsAppDelegate *)[[UIApplication sharedApplication] delegate];
//[[self navigationController] presentMoviePlayerViewControllerAnimated:[appDelegate movieController]];
[[appDelegate moviePlayer].view setFrame: self.view.bounds];
[self.view addSubview:[appDelegate moviePlayer].view];
[[appDelegate moviePlayer] setFullscreen:YES animated:YES];
}
以及以下听众:
#pragma mark - Movieplayer feedback
- (void)willEnterFullscreen:(NSNotification*)notification {
NSLog(@"willEnterFullscreen");
}
- (void)enteredFullscreen:(NSNotification*)notification {
NSLog(@"enteredFullscreen");
}
- (void)willExitFullscreen:(NSNotification*)notification {
NSLog(@"willExitFullscreen");
}
- (void)exitedFullscreen:(NSNotification*)notification {
NSLog(@"exitedFullscreen");
iDomsAppDelegate *appDelegate = (iDomsAppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate moviePlayer].view removeFromSuperview];
[[appDelegate moviePlayer] release];
[appDelegate setMovieController:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)playbackFinished:(NSNotification*)notification {
iDomsAppDelegate *appDelegate = (iDomsAppDelegate *)[[UIApplication sharedApplication] delegate];
NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
switch ([reason intValue]) {
case MPMovieFinishReasonPlaybackEnded:
NSLog(@"playbackFinished. Reason: Playback Ended");
break;
case MPMovieFinishReasonPlaybackError:
NSLog(@"playbackFinished. Reason: Playback Error");
break;
case MPMovieFinishReasonUserExited:
NSLog(@"playbackFinished. Reason: User Exited");
break;
default:
break;
}
[[appDelegate moviePlayer] setFullscreen:NO animated:YES];
}
只调用PlayBackFinished选择器(无限次),所以我必须做一些愚蠢的事情(在iOS5的模拟器中运行)
答案 0 :(得分:0)
我发现了问题,它似乎一直在设置导致它的全屏选项:
[[appDelegate moviePlayer] setFullscreen:YES animated:YES];