【发布时间】:2012-06-15 16:01:31
【问题描述】:
我有一个用户可以选择观看的视频列表。所有视频都包含在应用资源中并在本地播放。
除了一件事,我的一切都很好。我不知道如何强制视频播放为横向模式。
我正在使用此代码在选择视频时显示视频播放器:
- (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 应用类似的功能。
谢谢
【问题讨论】:
标签: iphone ios5 mpmovieplayercontroller