我的 iPhone 视频仅在纵向模式下播放 [英] My iPhone Video Only Plays in Portrait Mode

查看:27
本文介绍了我的 iPhone 视频仅在纵向模式下播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MPMoviePlayerController 播放电影.电影以纵向模式开始(因为这是应用程序使用的唯一模式),即使设备旋转也会停留在那里.我从未明确设置过 shouldAutoRotateetc.响应横向和纵向的功能,因为我不希望我的视图调整大小.有没有办法让视频响应纵向和横向旋转?任何帮助将不胜感激.

I am using MPMoviePlayerController to play a movie. The movie starts in portrait mode (as that's the only mode the app uses) and stays there even if the device is rotated. I never explicitly set the shouldAutoRotateetc. function to respond to landscape and portrait because I don't want my views resizing. Is there a way to get the video to respond to portrait and landscape rotations? Any help would be greatly appreciated.

仅供参考:这是我的代码

FYI: Here is my code

NSString *filepath = [[NSBundle mainBundle] pathForResource:@"TestMovie" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

//Listen so we can clean up after the movie is over
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

[self.view addSubview:moviePlayerController.view];
[moviePlayerController setFullscreen:YES animated:YES];
[moviePlayerController play];

推荐答案

嗯.行.在我被难住了半小时后想通了.

Hmm. OK. Figured it out a half-hour after I was stumped.

现在显然有一个 MPMoviePlayerViewController 可以处理所有这些.这是我的新更新代码:

There is apparently now an MPMoviePlayerViewController that handles all that. Here's my new updated code:

    MPMoviePlayerViewController *moviePlayerView = [[[MPMoviePlayerViewController alloc] initWithContentURL:videoURL] autorelease];
[self presentMoviePlayerViewControllerAnimated:moviePlayerView];

这将允许它响应旋转事件等.很好!

This will allow it to respond to rotation events, etc. Nice!

这篇关于我的 iPhone 视频仅在纵向模式下播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆