I have a client that would like background music to be playing while her students take a quiz. However, the quiz requires that certain audio files play through onclick effects. When a student clicks to play an audio file, my client would like the background music to mute, then resume playing once the onclick audio file is finished.
Is there any way to do this? Here is the code I'm using to fire the small, onclick audio effects:
var effect1 = document.createElement('audio');
effect1.setAttribute('src', 'audio.mp3');
$.get();
effect1.addEventListener("load", function() {
effect1.play();
}, true);
$('.effect1').click(function() {
effect1.play();
});
And here is my background music code:
<audio autoplay loop>
<source src="background.mp3">
</audio>
Any help is appreciated. Thanks!
Lauren