AVPlayer实例可以同时播放两个视频吗?
我目前正在使用 MPMoviePlayerController
在我的应用中播放视频。当我从一个视频切换到下一个视频时,这不是一个非常平滑的过渡。我得出的结论是,我需要做的是淡出第一个视频,同时淡入第二个视频。为此,我需要同时播放两个视频。我知道我无法使用 MPMoviePlayerController
做到这一点。它在文档中。可以用AVPlayer
来完成吗?我可以有两个 AVPlayer
实例,播放不同的电影,并在我的应用程序中同时播放,并且用户可以看到两部电影吗?
I'm currently using MPMoviePlayerController
to play videos in my app. When I switch from one video to the next, it's not a very smooth transition. I've come to the conclusion that what I need to do is fade the first video out while fading the second video in. To do that I'll need to have two videos playing simultaneously. I know I can't do that with MPMoviePlayerController
. It's in the documentation. Can it be done with AVPlayer
? Can I have two instances of AVPlayer
, playing different movies, playing at the same time in my app with both movies visible to the user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 MPMoviePlayer 一次只能播放一部电影。但是,您可以使用 AVPlayer 同时播放多个视频(在 AVFoundation 中,较低级别的音频视频框架)。查看此
You can only play one movie at a time using MPMoviePlayer. However, you can play multiple videos simultaneously using AVPlayer (in AVFoundation, lower level audio-video framework).. check out this example:
以下是一次播放 8 个,然后通过滚动一次再播放 8 个的方法:
请注意,drawPosterFrameForCell 方法将图像放置在无法播放视频的位置,因为它存储在 iCloud 上,并且不是设备。
Here's how you can play 8 at a time, and then play 8 more at a time by scrolling:
Note that the
drawPosterFrameForCell
method places an image where a video cannot be played because it is stored on iCloud, and not the device.MPMoviePlayerController
一次仅播放一个视频。但是,您可以使用
AVPlayer
同时播放多个视频。以下是同时播放多个视频的教程链接 - 同时播放视频
MPMoviePlayerController
plays only one video at a time.But, you can play multiple video simultaneously using
AVPlayer
.Following are the tutorial link for playing multiple video simultaneously - Play video simultaneously
如果您想在iOS应用程序中同时播放两个视频,请使用AVPlayer播放视频。
If you want to play two videos simultaneously in iOS app, use AVPlayer to play video.