HTML5--Audio tag

Source: Internet
Author: User

Definition and usage

<audio> tags define sounds, such as music or other audio streams.

Example code:
<audio src= "Someaudio.wav" >
Your browser does not support the audio tag.
</audio>


Hints and Notes

Tip: You can place text content between the start and end tags so that older browsers can display information that does not support that tag.

Property


Event method (temporarily not expanded)

Play () playback

Pause () pauses

Actual combat

JS Sample Code

<audio id= "audio" src= "No.mp3" > Tell you how many times, you just do not listen, so the low version of the browser is not replaced, what do you want to do? </audio><script type= "text/ JavaScript ">var audioele = document.getElementById (" audio "); Audioele.play ();     // play Audioele.pause ();    // Pause </script>

jquery Sample Code

<audio id= "audio" src= "No.mp3" > Tell you how many times, you just do not listen, so the low version of the browser is not replaced, what do you want to do? </audio><script type= "text/ JavaScript ">var audioele = $ (" #audio ") [0];audioele.play ();     // play Audioele.pause ();    // Pause </script>


Why does jquery need a 0? The JS operation obtains the audio object, the jquery selector obtains the jquery object, the 0 object is the corresponding node object. Therefore, it is not possible to use jquery objects directly, which needs to be supplemented with a bit of basic knowledge.

HTML5--Audio tag

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.