Home > Web Front-end > H5 Tutorial > 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
Release: 2016-05-16 15:50:42
Original
1955 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template