0
我有一個水平滾動視圖,就像Springboard一樣,每個頁面上都有16個按鈕。當你點擊一個按鈕時,我只想看看播放視頻的MPMoviePlayerController,就像在視頻應用程序中觀看電影一樣。因此,我得到以下代碼:Make MPMoviePlayerController main view
- (void)button: (id) sender {
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"MOV"];
NSURL *videoURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
moviePlayerController.fullscreen = YES;
[self.view addSubview:moviePlayerController.view];
[moviePlayerController play];
}
- (void)moviePlaybackComplete:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];
[moviePlayerController release];
}
不幸的是,我只能聽到聲音,沒有視頻顯示。有人可以幫我嗎?
更新:我發現你將不得不做一個框架。我用下面的代碼:
[moviePlayerController.view setFrame:CGRectMake(0, 0, 768, 1004)];
但它不是全屏的方式。即使我已將全屏屬性設置爲YES。我可以看到,因爲在視圖的頂部沒有視頻控件,但在視圖的底部。