允许同时创建多少个AVPlayer?

编程入门 行业动态 更新时间:2024-10-15 16:22:11
本文介绍了允许同时创建多少个AVPlayer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 collectionView ,每个单元格都有 AVPlayer 设置为播放。所以每个小区都在播放视频。 iOS似乎只允许您同时播放16个视频。例如,请查看下面的示例应用程序。在50个单元格中,只有16个开始播放视频。这个数字总是保持不变。这种情况发生在运行iOS 10的iPhone 6上。在Xcode模拟器中,所有50个视频都开始播放。此问题仅发生在实际设备上。

I have a collectionView and each cell has an AVPlayer which is set to play. So every cell is playing a video at the same time. It seems that iOS only allows you to play 16 videos at the same time. For example, look at my sample app below. Out of 50 cells, only 16 started playing a video. This number always stays the same. This happens on a iPhone 6s running iOS 10. In the Xcode simulator however all 50 videos start playing. This issue only happens on an actual device.

另外,当我打印出来时,我得到了这两个错误:

Also, I get these two errors when I print this out:

print("Video player Status Failed: player item error = (self.player.currentItem.error)") print("Video player Status Failed: player error = \(self.player.error)")

2016-11-07 15:53:46.548288 SampleApp [1810:515089]视频播放器状态失败:播放器项错误=错误域= AVFoundationErrorDomain代码= -11839无法解码UserInfo = {NSUnderlyingError = 0x1704414d0 {Error Domain = NSOSStatusErrorDomain Code = -12913(null)},NSLocalizedFailureReason =此媒体所需的解码器正忙。,NSLocalizedRecoverySuggestion =停止解码媒体的任何其他操作,然后重试。 ,NSLocalizedDescription =无法解码} 2016-11-07 15:53:46.548358 SampleApp [1810:515089]视频播放器状态失败:播放器错误=(null)

2016-11-07 15:53:46.548288 SampleApp[1810:515089] Video player Status Failed: player item error = Error Domain=AVFoundationErrorDomain Code=-11839 "Cannot Decode" UserInfo={NSUnderlyingError=0x1704414d0 {Error Domain=NSOSStatusErrorDomain Code=-12913 "(null)"}, NSLocalizedFailureReason=The decoder required for this media is busy., NSLocalizedRecoverySuggestion=Stop any other actions that decode media and try again., NSLocalizedDescription=Cannot Decode} 2016-11-07 15:53:46.548358 SampleApp[1810:515089] Video player Status Failed: player error = (null)

有多少限制AVPlayer 你可能有或者我做错了什么?

Is there a limit to how many AVPlayer's you could have or am I doing something wrong?

谢谢!

推荐答案

事实上,众所周知,AVPlayer实例的数量上限可以同时保持活动,但这个限制取决于运行代码的平台。 我自己发现在运行iOS 8的iPhone 5s上,有4个并发AVPlayer实例的限制。例如,此处,用户报告的限制为7 tvOS,2012年堆栈溢出报告的限制为4。

Indeed, it's common knowledge that there's an upper limit on the amount of AVPlayer instances you can keep alive at the same time, but this limit depends on the platform your code is running on. I myself have found that on an iPhone 5s running iOS 8, there was a limit of 4 concurrent AVPlayer instances. Here, for example, the user reports a limit of 7 for tvOS, and the same limit of 4 was reported in 2012 in stack overflow.

在任何情况下,这个限制都没有正式记录,这意味着它可以在平台和操作系统版本之间来回切换,因此除了将并发AVPlayer实例保持为尽可能低。

In any case, this limit not being officially documented means it can change back and forth between platforms and OS versions, so you should not base any code on this other than just keep concurrent AVPlayer instances as low as possible.

更多推荐

允许同时创建多少个AVPlayer?

本文发布于:2023-11-25 04:45:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628385.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多少个   AVPlayer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!