HTML5 background Music JS control play Pause

Source: Internet
Author: User

<HTML>    <Head>        <title>test Page</title>        <Scriptsrc= "Jquery.min.js"></Script><!--didn't try jquery, it's no use, I'm using getelementbyid-->.    </Head>    <Body>        <Scripttype= "Text/javascript"></Script>        <Audiosrc= "123.mp3"Controls= "Controls"ID= "Music1"AutoPlay>        </Audio>        <inputtype= "button"value= "Cough cough"onclick= "Bofang ()">        <Script>            functionBofang () {varAudio=document.getElementById ('Music1'); if(Audio!==NULL) {//To determine whether to obtainif(audio.paused) {//Get playback status, this property should be paused, if it is, pause audio.play () if it is not paused; }Else{audio.pause (); }                }            }        </Script>    </Body></HTML>

Explanation of the properties of the audio tag

AutoPlay Property Name AutoPlay value If this property appears, the audio plays immediately when it is ready.
Controls Controls If this property appears, the control is displayed to the user, such as the play button.
Loop Loop If this property appears, the playback starts again each time the audio ends.
Preload Preload

If this property appears, the audio loads when the page loads and prepares to play.

If you use "autoplay", the property is ignored.

Src Url The URL of the audio to play.

HTML5 background Music JS control play Pause

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.