HTML5 Examples For Beginners : Inserting Audio And Video
b. Inserting Audio
- Internet Explorer require .mp3 format
- Chrome can understand .mp3, .wav and .ogg formats
- Firefox can understand .wav and .ogg formats
- Safari can understand .mp3 and .wav formats.
For audio to work in all browsers you need to include all three formats. And if audio controls are not supported by browser you can use fall back mechanism by including flash file too.
Below is an example which include .mp3 and .ogg format.
<!DOCTYPE
html> <html> <head> <title>HTML5 Audio Control Example</title> </head> <body> <h1> HTML5 Audio Control</h1> <audio controls autoplay="autoplay"> <source src="Sleep.ogg" type="audio/ogg"> <source src="Sleep.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> </body> </html> |