允许同时创建多少个AVPlayer? [英] How many AVPlayers are allowed to be created at the same time?

查看:848
本文介绍了允许同时创建多少个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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆