HTML5 Mobile Development Road (--HTML5) audio in

Source: Internet
Author: User

This article is the official HTML5 training course for Brother Lian it education organization, mainly introduces: HTML5 Mobile Development Road (--HTML5) audio

Although the browser development is very fast, but the standard in the browser is still imperfect, in the html4+css2+js of the development of the front to many programmers headache is the browser compatibility problem, audio playback is the same, until now, there is still no web page to play video and audio standards. Now, in most browsers, audio is played through plugins (such as Flash plugins). However, not all browsers have such plugins, so the audio playback caused some trouble. In the new standard for HTML5, which provides a standard way to include audio through the sound element, let's look at the label in more detail below.

I. Support for audio formats

Currently, the audio element supports three different formats

  IE 9 Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0
Ogg Vorbis

MP3

Wav

Second, how to use

[HTML] view plain copy

Print? 650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "alt=" on Code View "Width=" "height=" 12 " Style= "border:0px;"/>650) this.width=650; "src=" Https://code.csdn.net/assets/ico_fork.svg "alt=" Derivation to My Code slice " Width= "height=" style= "border:0px;"/>

  1. <! DOCTYPE HTML>

  2. <html>

  3. <body>

  4. <audio src="Http://www2.shengda.edu.cn/ytw/gbzx/photo/bgmusic.mp3" controls= "controls ">

  5. The HTML5 tag is not supported by your browser

  6. </Audio>

  7. </Body>

  8. </html>

Click the Start button to play the song (in MP3 format, only for IE9 above and Chrome3.0 browser)

650) this.width=650; "Src=" http://img.blog.csdn.net/20140112125932921?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvzgf3yw5nyw5iyw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" border:0px; "/>

Control property Displays the console

The content inserted between <audio> and </audio> is displayed for browsers that do not support the audio element.

To run other browsers also support is to use the following methods

[HTML] view plain copy

Print? 650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "alt=" on Code View "Width=" "height=" 12 " Style= "border:0px;"/>650) this.width=650; "src=" Https://code.csdn.net/assets/ico_fork.svg "alt=" Derivation to My Code slice " Width= "height=" style= "border:0px;"/>

  1. <audio controls="Controls">

  2. <source src="Song.ogg" type="Audio/ogg">

  3. <source src="Song.mp3" type="Audio/mpeg">

  4. Your Browser does not support the audio tag.

  5. </Audio>

Iii. properties of the audio tag

Properties value Description
autoplay autoplay
controls controls
loop loop
preload preload

Src Url The URL of the audio to play.


HTML5 Mobile Development Road (--HTML5) audio in

Related Article

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.