Cocoa touch MPMoviePlayerController在轻敲时提供无休止的循环';完成';
我试图让MPMoviePlayerController工作,但遇到了一个奇怪的问题。播放时,我单击“完成”按钮,似乎触发了无限外观: 2012-02-13 15:18:04.395 iDomsPortalDev[7376:12203]播放完成。 原因:用户退出了2012-02-13 15:18:04.395 iDomsPortalDev[7376:12203] 游戏结束了。原因:用户退出2012-02-13 15:18:04.395 iDomsPortalDev[7376:12203]播放完成。原因:用户已退出 我在启动时使用以下通知:Cocoa touch MPMoviePlayerController在轻敲时提供无休止的循环';完成';,cocoa-touch,mpmovieplayercontroller,mpmovieplayer,Cocoa Touch,Mpmovieplayercontroller,Mpmovieplayer,我试图让MPMoviePlayerController工作,但遇到了一个奇怪的问题。播放时,我单击“完成”按钮,似乎触发了无限外观: 2012-02-13 15:18:04.395 iDomsPortalDev[7376:12203]播放完成。 原因:用户退出了2012-02-13 15:18:04.395 iDomsPortalDev[7376:12203] 游戏结束了。原因:用户退出2012-02-13 15:18:04.395 iDomsPortalDev[7376:12203]播放完成。
- (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];
}
仅调用PlaySelector(无限次),因此我一定做了一些愚蠢的事情(在带iOS5的模拟器中运行)我发现了问题,似乎是设置了全屏选项导致了问题:
[[appDelegate moviePlayer] setFullscreen:YES animated:YES];