I created a javascript audio player and i stored all media in this format:
var audios = {
fade: new Audio('music/fade.mp3'),
spectre: new Audio('music/spectre.mp3'),
force: new Audio('music/force.mp3')
}
and I am trying to stop them all with just one function, I am using audios['fade'].play()
, audios['spectre'].play()
and audios['force'].play()
to play them.
You could probably pass your audios object to a function with a for in loop to cycle through each property of your passed in object and turn it off.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in