AVAudio Engine and AVPlayerNode

I am working on music application where multiple wav files are scheduling within time frame. Everything is working perfect except one scenario where there is small beef is coming while scheduling player node again. For example - one.wav is playing on PlayerNode1 and now I am rescheduling to second.wav after 2 second then there is small beep is coming. I have tried to stop node by checking isPlaying condition. Still it is not working. Am I doing anything wrong here.

if playerNode.isPlaying {
    playerNode.stop()
}
playerNode.scheduleFile(audioFile, at: nil, completionHandler: nil)
playerNode.play()

I am using same player node for performance as there are 24 wav files that needs to be played in 1 minute so there is no point to keeping all player nodes.

How would stop beef while rescheduling new audio file for same player node?

I have shared link below to check issue. https://drive.google.com/file/d/1FjZtLUj_wUp0LQPyjIwfJNy67HWUlt0I/view?usp=sharing

Expected result should be song continuity

Replies

I have resolved this issue by creating own mixer node and attached to final output node. It was great experience. Click here to check gist