views:

373

answers:

2

here is code

- (void)applicationDidFinishLaunching:(UIApplication *)application {
  NSBundle *bundle = [NSBundle mainBundle];
 NSString *moviePath = [bundle pathForResource:@"sample_mpeg4" ofType:@"mp4"];
 NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];


 MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
 moviePlayer.movieControlMode =   MPMovieControlModeHidden;

 [moviePlayer play];

 [[NSNotificationCenter defaultCenter] addObserver:self 
 selector:@selector(moviePlaybackDidFinish:) 
 name:MPMoviePlayerPlaybackDidFinishNotification 
 object:nil]; 

 }
- (void) moviePlaybackDidFinish:(NSNotification*)notification
 {

MPMoviePlayerController *theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:theMovie];
[theMovie stop];
[theMovie release];

[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}

so my problem is my apps memory usage goes additional 3MB , it stays there even after release,does that mean memory does not get released?

A: 

Did you find the answer? i´m having the same problem!

Boozebum
nope...........
Nnp
A: 

Look at your code in - (void) moviePlaybackDidFinish:(NSNotification*)notification MPMoviePlayerController *theMovie = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];

Are you sure "theMovie" is your created "moviePlayer"? I believe they are different memory address because you didn't assign a object when you register the notification. Make sure

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];

Then try it again.

vicky