在 iPad 版 SDK 3.2 中使用 MPMoviePlayerViewController

发布于 2024-08-21 09:16:45 字数 220 浏览 4 评论 0原文

我开发了一个 iPhone 应用程序,它运行 MPMoviePlayer(3.2 SDK 之前的版本)没有任何问题。我知道这是一个新手问题,但如何让电影在新的 MPMoviePlayerViewController 中播放。我只收到音频并希望学习新的视图控制器。我已经将整个应用程序移植到 iPad 上,除了视频之外,其他一切都运行良好。有人可以展示一个使用电影视图控制器的示例吗?任何帮助将不胜感激。

谢谢,

I've developed an iPhone app that has been running MPMoviePlayer (pre 3.2 SDK) with no problems. I know this is a newbie question, but how do I get a movie to play in the new MPMoviePlayerViewController. I am only getting audio and wish to learn the new view controller. I've ported my whole app over to iPad and everything else works fine except for video. Could someone please show an example using the movie view controller? Any help would be appreciated.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

贱贱哒 2024-08-28 09:16:45
NSURL* videoURL = [NSURL URLWithString:url];
MPMoviePlayerController   moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer prepareToPlay];
[moviePlayer play];
//For viewing partially.....
[moviePlayer.view setFrame:CGRectMake(50, 200, (self.view.frame.size.width)-100 , 400)];
moviePlayer.view.backgroundColor = [UIColor grayColor]; 
[self.view addSubview:moviePlayer.view];    
NSURL* videoURL = [NSURL URLWithString:url];
MPMoviePlayerController   moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer prepareToPlay];
[moviePlayer play];
//For viewing partially.....
[moviePlayer.view setFrame:CGRectMake(50, 200, (self.view.frame.size.width)-100 , 400)];
moviePlayer.view.backgroundColor = [UIColor grayColor]; 
[self.view addSubview:moviePlayer.view];    
冰之心 2024-08-28 09:16:45

您需要使用 MPMoviePlayerViewController,而不是 MPMoviePlayerController。在文档中搜索 MPMoviePlayerViewController。

You need to use MPMoviePlayerViewController, not MPMoviePlayerController. Search the docs for MPMoviePlayerViewController.

小…红帽 2024-08-28 09:16:45

在您的视图控制器中尝试一下:

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

这应该可以帮助您入门,但请检查 MPMoviePlayerViewController 类参考以获取详细信息。

Try this in your view controller:

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

This should get you started but check the MPMoviePlayerViewController Class Reference for detailed info.

猛虎独行 2024-08-28 09:16:45

我一直在努力解决这个问题 - Apple 自己的 MoviePlayer 示例代码不能播放视频,只能播放音频。实际上我花了很长时间才发现它正在播放音频,因为他们提供的示例飞机视频没有音频轨道! (所以我点击按钮,却什么也没得到。)

感谢这里的所有建议。我终于找到了 https://developer.apple.com/library/ios /#qa/qa2010/qa1240.html
即便如此,这也是一个晦涩难懂的解决方案。

这有效:在 [mp 发布] 之后的 initAndPlayMovie 中:

[[self.moviePlayer view] setFrame:[window bounds]];// size to fit parent view exactly
[window addSubview:[self.moviePlayer view]];

一路顺风,快乐飞行:)

I've struggled all over the place with this - Apple's own MoviePlayer sample code doesn't play video, only audio. It actually took me ages to figure out that it was playing audio because the sample airplane video they supply has NO AUDIO TRACK!!! (So I click the button and get absolutely nothing.)

Thanks for all the suggestions here. I finally found https://developer.apple.com/library/ios/#qa/qa2010/qa1240.html
and even that is an obscure-ish fix.

This works: in initAndPlayMovie after [mp release]:

[[self.moviePlayer view] setFrame:[window bounds]];// size to fit parent view exactly
[window addSubview:[self.moviePlayer view]];

Bon voyage and happy flying :)

橘虞初梦 2024-08-28 09:16:45

更改此行:

MPMoviePlayerController  moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

需要 *

change this line:

MPMoviePlayerController  moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

to

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

you need the *

走走停停 2024-08-28 09:16:45

我很确定它目前在模拟器中坏了!我使用最新的 sdk 和他们自己的 MPMoviePlayer 示例代码以及苹果自己的视频得到相同的行为(没有视频,但听到音频),该代码将使用 safari 在 iPad 模拟器中播放...所以底线视频在 Safari 内部的模拟器 ipad 上播放,但不是来自使用 MpMoviePlayer 类的应用程序。错误或功能,由您决定。 (我认为它刚刚坏了)。此版本的发行说明在 MPMoviePlayer 类中进行了很多更改...

I am pretty sure that its broken in simulator at present ! I get same behavior (no video but hear audio) with latest sdk and their own MPMoviePlayer sample code with Apples own video that Will play in iPad simulator using safari... So bottom line video plays on simulator-ipad inside of Safari but Not from an app using MpMoviePlayer class. Bug or feature, you decide. (I think its just broken). release notes for this version have lots of changes going on in MPMoviePlayer class...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文