How to add the stop button action for the audio tag in html5 _ html5 tutorial tips-

Source: Internet
Author: User
In the html5 audio tag, there is only a pause button, but no stop button. In fact, it is not difficult to add it. Next we will introduce the implementation method, if you have any need, you can refer to the audio tag in html 5. There is only the pause button, but there is no stop button. In fact, it is not troublesome to add it. The method is as follows:

The Code is as follows:


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


In fact, it is very simple, that is, first pause, and then the time is set to 0;
Call Method:

The Code is as follows:


Var aud = new Audio ();
Aud. src = 'special .ogg ';
Aud. play ();
Aud. stop ();


The above code can be run in chrome or opera, but firefox 17 does not.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.