MPMoviePlayerController没有发布 [英] MPMoviePlayerController not released

查看:234
本文介绍了MPMoviePlayerController没有发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MPMoviePlayerController中运行一个介绍影片,我有一个问题,分配的内存没有被释放。

当电影完成,仪器显示释放的内存。

然而,当我通过点击跳过电影时,内存不会被释放。

这是我的代码的重要部分:

I am running an intro movie in a MPMoviePlayerController and i've got a problem with the allocated memory not being released.
When the movie finishes, Instruments shows the memory being released.
However when i skip the movie by tapping on it the memory is not released.
Here are the important parts of my code:

- (void)applicationDidFinishLaunching:(UIApplication *)theApplication {
self.application = theApplication; 
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"mymovie.mov" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; 
[window addSubview:moviePlayer.view];


moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.view.frame = window.frame;


UIView *introFrontView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
introFrontView.userInteractionEnabled = YES;
introFrontView.opaque = NO;
introTabRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self 
             action:@selector(introTabFrom:)];
[introFrontView addGestureRecognizer:introTabRecognizer];
[moviePlayer.view addSubview:introFrontView];
[introFrontView release];
[introTabRecognizer release];
self.moviePlayerController = moviePlayer;
[moviePlayer release];
[[NSNotificationCenter defaultCenter] addObserver:self 
        selector:@selector(introFinished:) 
         name:MPMoviePlayerPlaybackDidFinishNotification 
          object:self.moviePlayerController];
[self.moviePlayerController play];
}

- (void)introTabFrom:(UITapGestureRecognizer*)recognizer{
[[NSNotificationCenter defaultCenter] postNotificationName:MPMoviePlayerPlaybackDidFinishNotification
          object:self.moviePlayerController];
}

- (void) introFinished:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self
         name:MPMoviePlayerPlaybackDidFinishNotification
          object:self.moviePlayerController];
[self.moviePlayerController pause];
[self.moviePlayerController stop];
[self.moviePlayerController release];
...
}

我忘记了什么吗?根据我的理解,我发布了正确的通知...

任何想法?

Is there anything i forgot?
To my understanding i'm posting the correct notification...
Any ideas?

推荐答案

想要注册MPMoviePlayerPlaybackStateDidChangeNotification,并查看传入的playbackState。

You may want to register for MPMoviePlayerPlaybackStateDidChangeNotification, and look at the playbackState that is passed in.

这篇关于MPMoviePlayerController没有发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆