AVPlayerItemStatusFailed error when too many AVPlayer instances created

我是研究僧i 提交于 2019-11-30 22:36:53
bfich

If anyone comes across this same problem, I ended up creating a work around. Turns out that the number of AVPlayer instances is limited by iPhone hardware, I wish Apple made this more clear. This question touches on that.

In order to get around this limitation, I create and retain an AVURLAsset as well as an AVPlayerItem for each video I wish to play. When it's time to play the video, I create an AVPlayer instance on the fly (not a shared instance), add the AVPlayerItem to it, and play the video. After the video is done playing, I destroy the AVPlayer instance to free up the hardware. This is working well for me and my specialized situation, but some variation of this should help you too if you're experiencing the problem outlined above.

small rant:

I have been working fairly extensively with AVFoundation over the last couple of months, manipulating different types of media in lots of different ways. I frequently find myself cursing Apple's skeletal documentation and examples related to the AVFoundation framework. I wish they would bolster their docs for this as a lot of the framework is convoluted and unintuitive. This tiny rant in a dusty corner of the internet won't change anything but I guess I'm just venting.

end rant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!