Html5 sound stop

How to write a function that stops ALL instances of html5 sound playback 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();
});
+2
source share
3 answers
$.each($('audio'), function () {
    this.pause();
});

It simply finds all the elements <audio>in the DOM and uses the standard API to pause playback for each.

Here's a great tag reading <audio>and <video>: https://developer.mozilla.org/en/Using_HTML5_audio_and_video

Update

The documentation for the AudioPlayerV1script states how you pause an element <audio>:

$('#audio_id').AudioPlayerV1('pause');

Source: http://1.s3.envato.com/files/14653378/index.html#how-to-use

, AudioPlayerV1 () DOM .

Update

<audio>, :

$('audio').AudioPlayerV1('pause');

<audio> DOM AudioPlayerV1. , , . :

$.each($('audio'), function () {
    $(this).AudioPlayerV1('pause');
});
+9

js:

var ply = document.getElementById('player');

var oldSrc = ply.src;//

ply.src = "";// , .

+1

. .stop() .

$.each($('audio'), function () {
    this.pause();
});
0

All Articles