Think I tried everything here too.. None worked. Entire videos endedup getting buffered right after the following code snippet. Goal here is to quickly keep a lot of short video clips with only the beginnings pre-buffered, so that when users clicks into one of them they will play immediately, and only then have AVPlayer focus on trying to download the rest of that clip. Buffering the entire video clip for all the videos is not only a waste of users' bandwidth, but also given most network condition ends up that 90% of the time the video that the user ends up clicking on is not buffered at all... Playground Project test code I used:
@IBAction func startPrebuffer(_ sender: UIButton) {
for videoURLString in videoURLStringArray {
let avPlayerItem = AVPlayerItem(url: URL(string: videoURLString)!)
avPlayerItem.preferredForwardBufferDuration = TimeInterval(2.0)
let avPlayer = AVPlayer(playerItem: avPlayerItem)
avPlayer.automaticallyWaitsToMinimizeStalling = false
avPlayerArray.append(avPlayer)
}
Googling preferredForwardBufferDuration also only gives just a handful of result, mostly not related to this problem. Apple's documentation on this is also very disappointing....
This is Xcode 9.0. Base SDK 11.0, Target Deployment 10.0
Anybody filed a Radar on this by any chance already?