问题
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