How would I stream audio from a URL in Swift without downloading the mp3 file on the device? What do I need to import? Do I need certain libraries? Add anything to the info.plis
For online streaming you have to use AVFoundation framework.
var player: AVPlayer! let url = URL.init(string: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3") player = AVPlayer.init(url: url!)
To play:
player.play()
To pause:
player.pause()