Home  >  Article  >  Web Front-end  >  How to implement stop button action for audio tag in html5_html5 tutorial skills

How to implement stop button action for audio tag in html5_html5 tutorial skills

WBOY
WBOYOriginal
2016-05-16 15:50:421920browse

In the audio tag in HTML 5, there is only a pause button, but no stop button. In fact, it is not troublesome to add it. The method is as follows:

Copy code
The code is as follows:

HTMLAudioElement.prototype.stop = function()
{
this.pause();
this.currentTime = 0.0 ;
}

It’s actually very simple, just pause first and then return the time to 0;
Call method :

Copy code
The code is as follows:

var aud = new Audio();
aud.src = 'Special him.ogg ';
aud.play();
aud.stop();

The above code can be run under chrome and opera, but not firefox 17
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn