I have an MPMoviePlayerController
named myMoviePlayer
; I allocate and initialize it when my app loads:
NSString *moviePath = [bundle pathForResource:[movieName uppercaseString] ofType:@"mov" inDirectory:@"Videos"];
if(moviePath)
{
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
myMoviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[**myUI.view** setFrame:CGRectMake(80, 80, 600, 350)];
[self.view addSubview:myMoviePlayer.view];
myMoviePlayer.shouldAutoplay=NO;
}
There are two views in my app named imageView
and videoView
. I need to hide myMoviePlayer
in imageView
and display it again when my UI view is videoView
.
Each time I show a movie, movieName
will be different.
Right now, I am allocating and initializing myVideoPlayer
each time my view changes to the movie view. Is it possible to set a new video url to myMoviePlayer
without allocating it again?
Yes there is:
[myMoviePlayer setContentURL:[NSURL URLWithString:aMovieUrl]];
Just set the contentURL property of the MPMoviePlayerController instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With