如何显示“正在加载电影...”与 MPMoviePlayerController 的消息

发布于 2024-10-15 17:34:02 字数 716 浏览 2 评论 0原文

我正在使用适用于 iOS 平台的 MPMoviePlayerController,但不确定为什么加载新视频时不会自动显示“完成”和“正在加载电影...”控件。

我最初的实现是使用 UIWebView 控件来流式传输视频,当访问视频时,将显示“完成”和“正在加载电影...”控件,直到视频加载并准备好播放。我想使用 MPMoviePlayerController 重现相同的用户体验。

我应该免费获得“完成”和“正在加载电影...”控制叠加吗?如果没有,我必须设置什么才能让它们在视频加载时显示?

NSURL *videoUrl = [NSURL URLWithString:urlString];
self.moviePlayer = [[[MPMoviePlayerController alloc] init] autorelease];
self.moviePlayer.movieControlMode = MPMovieControlModeDefault;

[self.moviePlayer setContentURL:videoUrl];
[self.moviePlayer prepareToPlay];

[self.view addSubview:self.moviePlayer.view]; 
[[self.moviePlayer view] setFrame: [self.view bounds]];
[self.moviePlayer setFullscreen:YES animated:YES];

I'm working with the MPMoviePlayerController for the iOS platform and am not sure why the "Done" and "Loading Movie..." controls are not displaying automatically when loading a new video.

My original implementation of this was to use the UIWebView control to stream the videos, and when the videos are accessed, the "Done" and "Loading Movie..." controls are displayed until the video is loaded and ready to play. I would like to reproduce the same user experience with the MPMoviePlayerController.

Should I get the "Done" and "Loading Movie..." control overlays for free? If not, what do I have to set to get them to show up while the video is loading?

NSURL *videoUrl = [NSURL URLWithString:urlString];
self.moviePlayer = [[[MPMoviePlayerController alloc] init] autorelease];
self.moviePlayer.movieControlMode = MPMovieControlModeDefault;

[self.moviePlayer setContentURL:videoUrl];
[self.moviePlayer prepareToPlay];

[self.view addSubview:self.moviePlayer.view]; 
[[self.moviePlayer view] setFrame: [self.view bounds]];
[self.moviePlayer setFullscreen:YES animated:YES];

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

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

发布评论

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

评论(1

晨与橙与城 2024-10-22 17:34:02

这是您后续问题的答案,但无论如何......您可以通过以下方式加快速度:

准备播放
准备当前项目以供播放。 (必填)

- (void)prepareToPlay  

当您调用play方法时,会自动调用该方法。 在调用播放之前调用可以让接收者有机会更快地准备项目,并可能会减少开始播放时的延迟。但是,调用此方法也可能会中断任何活动的音频会话。

适用于 iOS 3.2 及更高版本。
在 MPMediaPlayback.h 中声明

This is answer to your follow-up question, but anyways... You can speed-up things a little bit with this:

prepareToPlay
Prepares the current item for playback. (required)

- (void)prepareToPlay  

This method is called automatically when you call the play method. Calling it before you call play gives the receiver a chance to prepare items sooner and may result in decreased latency when starting playback. However, calling this method may also interrupt any active audio sessions.

Available in iOS 3.2 and later.
Declared In MPMediaPlayback.h

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