I'm trying to use MPMoviePlayerController to play a video from bundle and it says "Use of undeclared identifier 'MPMoviePlayerController'". Do I need to import any library to use this class ? Also, I'd like to know how to NOT play it in full screen and how to choose the size of the box where it'll be played.
The code:
NSString *url = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
moviePlayer.shouldAutoplay=YES;
CGRect videoRect = CGRectMake(0, 0, 300, 250);
moviePlayer.view.frame = videoRect;
[self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer play];
You need to import/include the movie player: MediaPlayer/MediaPlayer.h
Also, the MediaPlayer.framework must be added to your "Frameworks" folder in the XCode project.
To not play in fullscreen:
self.moviePlayer.shouldAutoplay=YES;
CGRect videoRect = CGRectMake(0, 0, 300, 250); // define the player's dimensions in compact mode here its 300 * 250
self.moviePlayer.view.frame = videoRect;
[self.view addSubview:self.moviePlayer.view];