How to play AVPlayerItems immediately

為{幸葍}努か 提交于 2020-06-25 05:19:08

问题


I'm using AVPlayer which I connect to an remote URL via an AVPlayerItem. The problem is that I want to play the sound from the URL immediately and don't let the user wait for the AVPlayer to buffer.

The thing is that if the remote URL's asset media is very short then it doesn't buffer for long at all but if the media is a bit longer it takes a while.

Is there a way to skip the buffering process or at least shorten it substantially?


回答1:


Swift 5

You just need to use the automaticallyWaitsToMinimizeStalling property.

player.automaticallyWaitsToMinimizeStalling = false
player.playImmediately(atRate: 1.0)


来源:https://stackoverflow.com/questions/40628601/how-to-play-avplayeritems-immediately

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