In my ipad application I write a code to play a movie using MPMoviePlayerViewController
. Here how I have achieve it.
NSURL *url = [NSURL fileURLWithPath:self.moviePlayingTempPath];
// Initialize the movie player view controller with a video URL string
self.playerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:self.playerVC
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.playerVC.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.playerVC.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moveiPlayBackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.playerVC.moviePlayer];
self.playerVC.view.frame = CGRectMake(0, 0, 600, 500);
[self.view addSubview:self.playerVC.view];
// Start playback
[self.playerVC.moviePlayer prepareToPlay];
[self.playerVC.moviePlayer play];
Issue is player always run in fullscreen mode. But I want to change the movie player frame size.
I tried following [self.playerVC.moviePlayer setFullscreen:NO];
but no luck.
Here is the screen shot of my device. I use Xcode 4.6 and iOS 6 SDK.
I was able resolve this issue. There is a another view for movie player called MPMoviePlayerController. Then I was able to change the frame of the movie. Here is the updated code.
NSURL *url = [NSURL fileURLWithPath:self.moviePlayingTempPath];
// Initialize the movie player view controller with a video URL string
self.playerVC = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:self.playerVC
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.playerVC];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.playerVC];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moveiPlayBackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.playerVC];
[self.playerVC setControlStyle:MPMovieControlStyleDefault];
self.playerVC.view.frame = CGRectMake(0, 0, 600, 500);
[self.view addSubview:self.playerVC.view];
// Start playback
[self.playerVC prepareToPlay];
[self.playerVC play];