HTML5 a lot of new things, and the old version of some different, this article will tell the HTML5 of the new audio elements of the detailed analysis
HTML5 Audio (voice)
Last modified August 01, 2017
HTML5 provides the standard for playing audio files.
Audio on the Internet
Until now, there is still no standard for playing audio on a Web page.
Today, most audio is played through plugins (such as Flash). However, not all browsers have the same plugin.
HTML5 specifies the standard for embedding audio elements on a Web page, that is, the use of <audio> elements.
Browser support
Internet Explorer + +, Firefox, Opera, Chrome, and Safari all support <audio> elements.
Note: Internet Explorer 8 and earlier IE versions do not support the <audio> element.
HTML5 Audio-How to work
To play audio in HTML5, you need to use the following code:
<! DOCTYPE html>
Your browser does not support the audio element.
</audio>
</body>
The control property is used to add play, pause, and volume controls.
Between <audio> and </audio> you need to insert the hint text of the <audio> element that the browser does not support.
The <audio> element allows multiple <source> elements to be used. <source> elements can link different audio files, the browser will use the first supported audio file
Audio format and browser support
Currently, the <audio> element supports three audio format files: MP3, Wav, and Ogg;
MIME type of audio format: MP3, Ogg, Wav;
Html5audio Tags:
<audio> Definition of sound content
<source> provides multimedia resources, which can be multiple, used in <video> and <audio> tags
Properties of the <audio> tag:
AutoPlay: If this property appears, the audio plays immediately when it is ready.
CONTROLS: If this property appears, the control is displayed to the user, such as the play button.
Loop: If this property occurs, the playback starts again each time the audio ends.
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: The URL of the audio to play.
The content inserted between <audio> and </audio> is displayed for browsers that do not support the audio element: <audio src= "Song.ogg" controls= "Controls" >your Browser does not support the audio tag.</audio>
The above example uses an Ogg file for Firefox, Opera, and Chrome.
To ensure that the audio file must be MP3 or Wav type for Safari browser.
The audio element allows multiple source elements. The source element can link different audio files. The browser will use the first recognizable format:
<audio controls= "Controls" > <source src= "Song.ogg" type= "Audio/ogg" > <source src= "Song.mp3" Type= "Audio/mpeg" >your browser does not support the audio tag.</audio>
"Recommended"
HTML base element that gives you 0 basic learning HTML
Analysis in the HTML5