I am attempting to create an iOS application that takes various audio files from the Files app and plays them inside the app using the AudioKit framework. However, from what I have researched, AudioKit's file API appears to be incompatible with external URLs. Does anybody know any alternative music-based frameworks or methods, that can play audio files that are external URL based?
Asked
Active
Viewed 56 times
0
-
Not exactly your issue, but [this](https://stackoverflow.com/questions/34563329/how-to-play-mp3-audio-from-url-in-ios-swift) should basically cover what to do. – Daniel Jun 28 '20 at 00:11
1 Answers
-1
This is the another way. We can play audio with AVPlayer without download. No need to download the audio, with streaming we can play. Check below code.
let url = URL(string:"https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3")
let playerItem:AVPlayerItem = AVPlayerItem(url: url!)
let player = AVPlayer(playerItem: playerItem)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = CGRect(x:0, y:0, width:200, height:200)
self.view.layer.addSublayer(playerLayer)
player.volume = 1.0
player.play()

Tajinder singh
- 738
- 1
- 9
- 18