How to release MPMoviePlayerController?

Posted by 4thSpace on Stack Overflow See other posts from Stack Overflow or by 4thSpace
Published on 2009-03-29T20:23:46Z Indexed on 2010/05/05 15:48 UTC
Read the original article Hit count: 687

I have a couple of views that access the movie player. I've put the following code in a method in AppDelegate for these views. They send in the filename to play. The code works fine but I know a release is required somewhere. If I add the last line as a release or autorelease, the app will crash once the user presses done on the movieplayer.

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] 
                 initWithContentURL:[NSURL fileURLWithPath:moviePath]];
moviePlayer.movieControlMode = MPMovieControlModeDefault;
[moviePlayer play];
//[moviePlayer release];

I get this error:

objc[51051]: FREED(id): message videoViewController sent to freed object=0x1069b30

Program received signal: “EXC_BAD_INSTRUCTION”.

How should I be releasing the player?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk