dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.
MIT License
266 stars 56 forks source link

Playing an url and then queueing others will remove some of the queued urls #46

Closed GeorgeIvanov closed 1 year ago

GeorgeIvanov commented 2 years ago
let player = AudioPlayer()
player.play(url: URL(string: "https://your-remote-url/to/audio-file.mp3")!)
player.queue(urls: [
    URL(string: "https://your-remote-url/to/audio-file.mp3")!,
    URL(string: "https://your-remote-url/to/audio-file.mp3")!
])

the

sourceQueue.async { [weak self] in
            guard let self = self else { return }
            self.processSource()
        }

from the play() method will call the processSource() which will clear the queue after it was populated. My assumption being that the first lines of code are correct and the queueing of the URLs should be called after the play method which starts the audio engine if needed.

dimitris-c commented 2 years ago

play method will clear the queue, so the above is correct in the sense of, if you want to play multiple items in a queue you would use queue instead of play - queue will start playing the first item.

If you want play and then queue item up you'll have to do it with a tap of a button or after perhaps the delegate called audioPlayerDidStartPlaying