开发者

MPMoviePlayerController memory not released when video not completely played

In ipad when video played using MPMoviePlayerController large memory allocated . That memory is released if the video played to the end ,but when navigate away from the view without the end of the video the memory allocated is not completely released.I want release all the memory associated with the player when the user want to navigate away from the view (even if the video not played to the end) .Please guide me on how this can be achieved.

-(void)playMovieAtURL:(NSURL*)theURL

{

   player = [[MPMoviePlayerController alloc] initWithContentURL:theURL];

   CGRect frame= CGRectMake(0.0,60.0,768.0,650.0);

   [[player view] setFrame:frame]; 

   [[NSNotificationCenter defaultCenter] addObserver:self     selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification ob开发者_StackOverflowject:player];   

   [self.view addSubview:player.view];

   [player play];

}

-(void)moviePlayBackDidFinish: (NSNotification*)notification{

[player.view removeFromSuperview];
[player stop];
player.initialPlaybackTime = -1.0;
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player] ;
[player release];
player=nil;

}

given below is the function for getting diffrent slides like viedo or picture

-(void)getSlide

{ if(player !=nil) {

    if(urlp !=nil)
    {
        [urlp release];
        urlp=nil;

    }
    [player pause];
    [player stop];

}

..... .... ....

 if(type =video)

   {
          urlp =[[NSURL alloc] initFileURLWithPath:toPlay];
          [self playMovieAtURL:urlp];
          [urlp release];


    }

}


I think [player release]; and player = nil; should do it. Make sure you do this before navigating to another view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜