Reputation:
I have multiple audio files and i want to make it pause/stop all others if one plays.
This is how it looks like and i have jquery if that ease the solution:
<audio controls="">
<source type="audio/ogg" src="asdf.ogg"></source>
<source type="audio/mpeg" src="asdf.mp3"></source>
</audio>
<audio controls="">
<source type="audio/ogg" src="asdf.ogg"></source>
<source type="audio/mpeg" src="asdf.mp3"></source>
</audio>
<audio controls="">
<source type="audio/ogg" src="asdf.ogg"></source>
<source type="audio/mpeg" src="asdf.mp3"></source>
</audio>
Upvotes: 0
Views: 1706
Reputation: 2819
Hi in jQuery like this:
$("audio").on("play", function(){
var _this = $(this);
$("audio").each(function(i,el){
if(!$(el).is(_this))
$(el).get(0).pause();
});
});
now you could try it your self in JS, and post it, to show that you tried something yourself!
Upvotes: 2