在 iPhone 应用程序中缓冲、切换和循环播放视频,以模拟不间断的视频源

发布于 2024-08-15 18:18:38 字数 213 浏览 4 评论 0原文

我(还)不是 iPhone 开发者。如果这个问题是非常基本的问题,请原谅。

根据我从开发文档中收集到的信息,一次只能“播放”一个视频文件。

我的要求是从一个视频无缝切换到另一个视频,或者切换到第一个视频的第二个实例并保持“循环”。

是否可以加载/缓冲第二个视频,以便视频可以连续播放,从而产生持续视频源的效果?或者,“播放”2 个视频,但屏幕上同时只显示一个视频?

I am not an iPhone developer (yet). So please excuse me if this issue is very basic question.

From what I can gather from the development documentation, it is only possible to 'play' one video file at a time.

The requirement I have is to switch from 1 video to another seamlessly or switch to a 2nd instance of the first video and keep 'looping'.

Is it possible to load/buffer a 2nd video so that videos can be seamlessly played after each other to give the effect that there is a constant video feed? Or, 'playing' 2 videos but only having one on screen at any one time?

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

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

发布评论

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

评论(3

时光匆匆的小流年 2024-08-22 18:18:38

不幸的是(令我厌恶的是)你无法创建无缝循环。然而,您可以观察/收听一个 MPMoviePlayerPlaybackDidFinishNotification 通知/事件,它本质上在电影播放完毕时为您提供一个事件。您可以使用它来播放下一个视频或重复刚刚播放的视频。

缺点是 MPMoviePlayerController 在播放完毕后会将上一部电影淡出(到背景颜色),这会阻止我们连续循环。如果您的视频没有声音,我建议提取帧并使用 UIImageView 播放它们,如果它确实有音频,那么(像我一样)您会有点卡住!

祝你好运。

Unfortunately (and much to my disgust) you cannot make a seamless loop. There is however a MPMoviePlayerPlaybackDidFinishNotification notification/event that you can observe/listen to which essentially gives you an event when the movie has finished playing. You can use this to play the next video or repeat the one you just played.

The down side is that the MPMoviePlayerController fades the previous movie out (to the background color) when it has finished playing which stops us from looping continuously. If your video does not have sound, I would suggest extracting the frames and playing them back with a UIImageView, if it does have audio, then (like me) you are kind of stuck!

Good luck.

瑾夏年华 2024-08-22 18:18:38

您可以在 iPad 上使用 iOS 3.2+ 循环播放视频。为了针对 iPhone 进行编译,我必须使用 4.1 的基础 SDK(4.0 也应该可以)

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:nsUrl];
moviePlayer.repeatMode = MPMovieRepeatModeOne;
[mp play];

这篇文章帮助我进行了设置:
http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html

You can loop a video with iOS 3.2+ on iPad. To compile for iPhone I had to use a base SDK of 4.1 (4.0 should work as well)

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:nsUrl];
moviePlayer.repeatMode = MPMovieRepeatModeOne;
[mp play];

This article helped me set things up:
http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html

电影里的梦 2024-08-22 18:18:38

从 iPhone SDK 3.1.3 开始,MPMoviePlayer 无法执行此操作。请密切关注未来的 SDK 更新。

As of IPhone SDK 3.1.3 the MPMoviePlayer cannot do this. Keep an eye out for future SDK updates.

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