Audio (and video) streaming would be a great topic to cover. I’ll keep it in mind as I plan new episodes.
The short answer to your question is that streaming MP3s (or AACs) is essentially downloading the file progressively and feeding that data to a player as it is downloading.
You may have looked at
AVAudioPlayer, but that class really just wants to work with local resources. To stream audio files from remote URLs, use
AVPlayer. It looks like this:
let player = AVPlayer(url: urlToResource)
This will handle all of the buffering for you silently and you have basically no control or feedback over how it is working. I recommend to drop down to AVURLAsset and AVPlayerItem so you can observe the properties and know more about when things are downloading, when it is ready to play, etc.
let asset = AVURLAsset(url: urlToResource)
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer(playerItem: playerItem)
There’s a ton of power in these APIs, so definitely read the docs.
Lastly, I want to mention that HTTP Live Streaming is not just for “live” content. It’s more about HTTP Streaming than it is about “Live”. I use HTTP Live Streaming (with encryption) to serve up video to the iOS and tvOS apps for NSScreencast. It works really well, but takes a little time to set it all up.
Hope this helps!