在我的ipad应用程序中,我编写了一个使用MPMoviePlayerViewController
播放电影的代码。在这里我是如何实现它的。
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];
问题是玩家总是以全屏模式运行。但我想改变电影播放器的帧大小。
我试过跟[self.playerVC.moviePlayer setFullscreen:NO];
但没有运气。
这是我的设备的屏幕截图。我使用Xcode 4.6和iOS 6 SDK。
答案 0 :(得分:0)
我能解决这个问题。电影播放器还有一个名为MPMoviePlayerController的视图。 然后我就能改变电影的画面。这是更新的代码。
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];