All I want is to wait until the sound is finished and call the next sound...
This is main function in the ConentView struct I'm using to play the sounds with handlers:
func askNew(){
self.isPlaying = true
playQuestion{
//1st audio
askNew{
//2nd audio to play
//Change the global @State to see the result
self.isPlaying = false
}
}
}
}
Small functions to play the sounds. Obviously, they let us know only if the audio session starts, but does not await for the ending.
// MARK: - Question
func playQuestion(finished: () -> Void) {
GSAudio.sharedInstance.playSound(sound: "question", type: "mp3", loop: false)
finished()
}
func askNewSetCurrent(finished: () -> Void){
GSAudio.sharedInstance.playSound(sound: "next_sound", type: "mp3", loop: false)
finished()
}