2010-11-02 54 views
0

我有3个电影播放器​​添加到三个不同的视图。当电影只播放几秒钟后,我在视图之间随机切换时,在所有后续视图中,蓝屏将消失。MPMoviePlayerController在切换后消失Views

我不释放我认为任何地方的话,我想不通为什么我的球员消失

这里是我在查看ID Load方法与通知方法一起使用的代码。

movieUrl =[[NSBundle mainBundle] pathForResource:@"Old Spice-Ad" ofType:@"mp4"]; 

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:movieUrl]]; 

player.view.frame =CGRectMake(38,380,211,122); 

[self.view addSubview:player.view]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:player] ; 



- (void)moviePlayBackDidFinish:(NSNotification *)notification { 
    MPMoviePlayerController *theMovie = [notification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                name:MPMoviePlayerPlaybackDidFinishNotification 
                object:theMovie]; 
    [theMovie stop]; 
    [theMovie release]; 
} 

回答

1

在的MPMoviePlayerController类的引用:

注:虽然您可以创建多个的MPMoviePlayerController对象,并在你的界面提出自己的看法,只有一次一个电影播放器​​可以发挥其电影。