Hello,
I realise that a similar question has been posted before, but I really can't seem to find a solution that works for me. I have a MoviePlayer class which stores an ivar of MPMoviePlayerController, and I have the following method in the class:
-(void)playMovie:(NSString *)movieName
{
NSURL *movieURL;
NSBundle *bundle = [NSBundle mainBundle];
if(bundle)
{
NSString *moviePath = [bundle pathForResource:movieName ofType:@"m4v"];
if(moviePath)
{
movieURL = [NSURL fileURLWithPath:moviePath];
}
}
MPMovieController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if(mp)
{
self.moviePlayer = mp;
[mp release];
[self.moviePlayer play];
}
[movieURL release];
}
When call I play movie once the movie plays fine, but when it is called again on a different (or the same) movie file I get the following error stack:
_class_isInitialized
_class_lookupMethodAndLoadCache objc_msgSend
-[MoviePlayer setMoviePlayer:]
-[MoviePlayer playMovie:]
I'm not sure how to fix it! I assumed that when self.moviePlayer = mp is called then the current moviePlayer is released and the new one is added? The property is set to (nonatomic, retain). Can someone help please?
Thanks