【发布时间】:2011-12-01 16:35:46
【问题描述】:
我有 MPMoviePlayerViewController 的问题,当应用程序进入后台然后我再次启动它或转到另一个 viewControllers 时,电影变黑了!我有在我的菜单背景中播放的电影,这是我的代码:
EIDTED 代码:
-(void)viewDidLoad {
[self moviePlayer2];
}
- (void) moviePlayer2 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"cloud" ofType:@"mp4"];
player = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
player.view.userInteractionEnabled = YES;
player.moviePlayer.repeatMode = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeFill;
player.moviePlayer.controlStyle = MPMovieControlStyleNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackStateChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:[player moviePlayer]];
[[player moviePlayer] play];
[self.view addSubview:player.view];
}
-(void) moviePlayBackStateChange: (NSNotification *) note {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:[player moviePlayer]];
[[player moviePlayer] play];
//[player release];
NSLog(@"FINISHED");
}
谢谢。
【问题讨论】:
-
当您的应用进入后台时,
movieFinishedPlaying是否会被调用?如果你不知道,设置一个断点(或使用 NSLog 到控制台)并找出。 -
当我在 viewControllers 之间切换时 yes 。编译器显示 NSLog 消息
标签: iphone ios xcode ipad mpmovieplayercontroller