So far I’ve been working on a multiple audio playback project using AKPlayers, triggered by AKSequencer to obtain perfect sync, looping and advanced signal processing. It’s been going well, but now I need some insight before I jump into the next level.
I am trying to play the exact same function with remote mp3 files - streaming arrays of mp3 files from remote URL address. However, AKPlayer so far doesn’t seem to support streaming functionality.
One possibility I found on this website, though, is Ryan Francesconi’s answer on the thread "How can I get AudioKit to stream an audio file from a remote URL?”. Here’s how he suggested:
guard let remote = URL(string: "https://www.sample-videos.com/audio/mp3/crowd-cheering.mp3"),
let data = NSData(contentsOf: remote) else {
AKLog("Remote failed to load.")
return
}
let cachedFile = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(remote.lastPathComponent)
try? data.write(to: cachedFile)
let player = AKPlayer(url: cachedFile)
So, before I start experimenting with this, could anybody (Mr. Francesconi, ideally) inform me how to implement this code on iOS? Would it be safe(in terms of seamless sync and looping) to develop with this cache-and-load idea for a multiple audio file playback project? Would be extremely helpful if I can learn more about this point. Much appreciated. <3