2012-06-15 35 views
0

我有一個用戶可以選擇觀看的視頻列表。所有視頻都包含在應用資源中並在本地播放。肖像中的視頻列表;在景觀中播放視頻

我有一切工作很好,除了一件事。我無法弄清楚如何強制視頻播放進入橫向模式。

我使用這個代碼時選擇視頻顯示視頻播放器:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    VideoPlayerViewController *detailViewController = [[VideoPlayerViewController alloc] init]; 
    detailViewController.delegate = self; 

    detailViewController.contentPath = [[videos objectAtIndex:indexPath.row] objectAtIndex:1]; 

    [self presentModalViewController:detailViewController animated:YES]; 
} 

我的播放器類,VideoPlayerViewController加載使用的contentPath在上面的代碼中設置播放器和播放視頻。

我可以旋轉我的手機並切換到風景,但如果我將手機旋轉回肖像,視頻也會旋轉。我的播放器有以下代碼:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

任何想法爲什麼它允許旋轉回肖像以及如何在景觀中開始播放?

我正在尋找與本機YouTube應用類似的功能。

感謝

回答

0

使用這VideoPlayerViewController viewDidLoad方法和shouldautorotate方法:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; 

[[self view] setBounds:CGRectMake(0, 0, 480, 320)]; 
[[self view] setCenter:CGPointMake(160, 240)]; 
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI/2)]; 
+0

這是真棒Safecase。它完美的作品。非常感謝你。 – kinadian