dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

GeorgeIvanov opened this issue · comments

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.

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