Im using an AVAudioPlayerNode
to loop playback of an audio file in buffer and need to be able to switch to the next track when the user clicks next but switch at the end of the loop instead of as soon as the user clicks next
Here's the code I use to start playback
if loopPlayback == true {
audioPlayer.scheduleBuffer(buffer, at: nil, options: .loops, completionHandler: nil)
audioPlayer.play()
playPauseToggleState()
}