I have very large wav files (1.5+ GB — for 7.4.1 sound) and when I stream them with AVPlayer, they take 5+ minutes to load before starting. It seems to be downloading the entire file first and then playing it. Even if I use an mp3 version (75+ MB), it will download for over a minute before playing.
I also tried:
playerItem.preferredForwardBufferDuration = 10
let player = AVPlayer(playerItem: playerItem)
player.automaticallyWaitsToMinimizeStalling = false
with no success.
I have tried using SwiftAudioPlayer and other modules that use AVEngine, and the sound starts right away, but the UI freezes and the sound stutters badly.
The sound works properly and well with Sola42d (my preferred framework), but I cannot then play the sound in the background, with the app suspended. I have built my project with Solar2d and then added Swift modules to play the AVPlayer (solving the background problem), but can’t get over those problems — either it waits for minutes before playing or it saturates the CPU and stutters.
What are my options? To code from scratch using AVEngine with buffers and background download (I am a beginner with Swift)? Are there any settings for AVPlayer that make streaming work for large files?