To play audio in HTML5, you need to use the following code:
<controls> <src= "Horse.ogg" type = "Audio/ogg" > < src= "Horse.mp3" type= "Audio/mpeg"> Your browser does not support the audio element. </audio>
Control property for adding 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 types of audio format files: MP3, Wav, and Ogg:
Browser |
MP3 |
Wav |
Ogg |
Internet Explorer + |
YES |
NO |
NO |
Chrome 6+ |
YES |
YES |
YES |
Firefox 3.6+ |
YES |
YES |
YES |
Safari 5+ |
YES |
YES |
NO |
Opera |
YES |
YES |
YES |
MIME type for audio format
Format |
Mime-type |
MP3 |
Audio/mpeg |
Ogg |
Audio/ogg |
Wav |
Audio/wav |
18. HTML5 Audio File