How would I write a function that stops ALL instances of playing html5 audio in the DOM?
html5 audio
<audio class="AudioPlayerV1" preload="none" width="292">
<source src="test.mp3" type="audio/mpeg" />
</audio>
js
AudioPlayerV1('*').each(function() {
this.setStop();
});
This just finds all the
<audio>elements in the DOM and uses the standard API to pause the playback for each.Here’s some excellent reading about
<audio>and<video>tags: https://developer.mozilla.org/en/Using_HTML5_audio_and_videoUpdate
The documentation for the
AudioPlayerV1script states this is how you pause an<audio>element:Source: http://1.s3.envato.com/files/14653378/index.html#how-to-use
It looks like the
AudioPlayerV1plugin is supposed to be called on a selection of DOM element(s) and passed in an option.Update
To run the plugin to pause multiple
<audio>elements you should be able to do this:Which selects the
<audio>elements in the DOM and passes them to theAudioPlayerV1plugin. the plugin should be written to handle this but if it isn’t then you have to call the plugin on each element. Inside a loop would be easiest: