May 03, 2021 HTML5
HTML5 provides the standard for playing audio files.
By using the audio feature in HTML5, you can implement the same functionality as flash, i.e. playback, jump, buffering, and so on.
Until now, there was no standard for playing audio on a Web page.
Today, most audio is played through plug-ins such as Flash. However, not all browsers have the same plug-in.
HTML5 sets out the criteria for embedding audio elements on a Web page, i.e., using the element.
Internet Explorer 9 Plus, Firefox, Opera, Chrome, and Safari all support the elements.
Note: Internet Explorer 8 and earlier versions of IE do not support the element.
To play audio in HTML5, you need to use the following code:
Control property to add playback, pause, and volume controls.
Between the sl;audio> and the slt;/audio> you need to insert the prompt text of the element that the browser does not support.
The element is allowed to use more than one element. The element can link different audio files, and the browser will use the first supported audio file
Currently, the element supports three audio format files: MP3, Wav, and Ogg:
Browser | MP3 | Wav | Ogg |
---|---|---|---|
Internet Explorer 9+ | YES | NO | NO |
Chrome 6+ | YES | YES | YES |
Firefox 3.6+ | NO | YES | YES |
Safari 5+ | YES | YES | NO |
Opera 10+ | NO | YES | YES |
Format | MIME-type |
---|---|
MP3 | audio/mpeg |
Ogg | audio/ogg |
Wav | audio/wav |
Label | Describe |
---|---|
<audio> | The sound content is defined |
<source> | A multimedia resource is specified, which can be multiple, and is used in the hashtags of slt;video> and slt;audio?gt; |
HTML DOM Reference Manual: HTML DOM Audio Object