I have the following javascript code
var audio = new Audio('{{ path }}');
function play() {
audio.play();
}
statusElement = document.getElementById("audio-status")
statusElement.innerHTML = "Playing the audio"
play()
statusElement.innerHTML = "done playing the audio"
Now, when I run this code, I see that the statusElement displays "done playing the audio" while the audio is still playing.
I think that this might be because the audio.play() function runs asynchronously, however, that's not what I want.
I want to first display, "Playing the audio", and then wait for the audio to play, and after that display "done playing the audio". How should I go about doing this?