HTML5 Audio (Audio)
HTML5 provides a standard play audio files.
Audio on the Internet
Until now, still does not exist a program to play audio standard on the web.
Today, most audio through the plug-ins (such as Flash) for playback. However, not all browsers have the same plugins.
HTML5 provides embedded audio standard elements on the page, using <audio> element.
Browser Support
Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the <audio> element.
Note: Internet Explorer 8 and earlier versions of IE do not support the <audio> element.
HTML5 Audio - How It Works
To play audio in HTML5, you need to use the following code:
Examples
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
您的浏览器不支持 audio 元素。
</audio>
property for added control play, pause and volume control.
In the <audio> and </ audio> between you need to insert your browser does not support the prompt text <audio> element.
<Audio> element allows the use of multiple <source> element. <Source> elements can link to different audio file, the browser will use the first supported audio files
Audio formats and browser support
Currently, <audio> element supports three audio formats: MP3, Wav, and Ogg:
浏览器 | MP3 | Wav | Ogg |
---|---|---|---|
Internet Explorer 9+ | YES | NO | NO |
Chrome 6+ | YES | YES | YES |
Firefox 3.6+ | YES | YES | YES |
Safari 5+ | YES | YES | NO |
Opera 10+ | YES | YES | YES |
MIME type of audio format
Format | MIME-type |
---|---|
MP3 | audio/mpeg |
Ogg | audio/ogg |
Wav | audio/wav |
HTML5 Audio tag
label | description |
---|---|
<audio> | It defines audio content |
<source> | Provides multimedia resources, it may be more than one, use the <video> and <audio> tag |