0
我已經經歷了一堆其他的例子,但我無法得到一個視頻來加載一個viewController的全屏。iPhone MediaPlayer - 全屏?
我可以讓它加載...但不能全屏啓動。
代碼如下。謝謝!
-(void)viewWillAppear:(BOOL)animated {
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
[moviePlayerController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player autorelease];
}
編輯:全屏固定...我只是不得不補充:moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
現在它增加了一個奇怪的圖像到我的狀態欄..見附圖。
感謝Walter ......我的全屏意思是讓「完成」按鈕在啓動時顯示,而不必先點擊全屏按鈕。 –
謝謝沃爾特......我添加了'moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;'這似乎有點解決它。現在,我在狀態欄中看到一個奇怪的圖像...查看我更新的圖像問題。 –