Reputation: 83
I have a soundfile running automatically and on repeat during on website. Since it's a simple game, sometimes after user takes certain actions I have dialogues or video clips played and the main music in the background interferes with that.
I tried using .pause() function and it indeed pauses the music, but I didnt find an efficient way of turning it back on again after the certain clip is played. Perhaps setTimeout function could work, but that wouldnt be very efficient to determine how long said clip lasts
Upvotes: 1
Views: 45
Reputation: 336
You can pause the main (loop) audio when the dialogs are triggered and listen for their end to resume playing the main audio file.
Listen to audio/video ending: https://www.w3schools.com/tags/av_event_ended.asp
Upvotes: 2