[英]iPhone SDK 4: video autorotation from MPMoviePlayerViewController
拜托你給的例子shouldAutorotateToInterfaceOrientation
方法用法MPMoviePlayerViewController的一部分嗎? 據我所知,使用shouldAutorotateToInterfaceOrientation
方法不僅可用於UIView的同時也為MPMoviePlayerViewController SDK 3.2以來。 我一直在3.1的UIView中使用它,但是我不明白如何在MPMoviePlayerViewController類中使用它。
這是我現在擁有的:
-(IBAction) playMovie {
//declaring path to file and stuff...
MPMoviePlayerViewController *playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:[playerViewController moviePlayer]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:[playerViewController moviePlayer]];
MPMoviePlayerController *player = [playerViewController moviePlayer];
[self.view addSubview:playerViewController.view];
player.controlStyle = MPMovieControlStyleDefault;
player.shouldAutoplay = YES;
[player setFullscreen:YES animated:YES];
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerViewController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[moviePlayer release];
}
它工作正常,但我需要知道如何實現視頻自動旋轉。 UIView中用於它的方法無濟於事。
謝謝。
嗯,聽起來很奇怪,但是我確定此方法一定不能聲明為ideide playMovie塊。 我錯了,下面的代碼像往常一樣粘貼,並且可以滿足我的需要。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else {
return NO;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.