HTML5 Audio

  • We can add multimedia elements to our webpages with <audio> and <video> elements.
  • Inside the <audio> element you need to add a series of <source> elements.
  • Different browsers support different formats. By creating multiple copies of the same audio file you can support all the browsers. Each <source> element will point to a different format.
  • The browser will load and run the first format that it supports.
<audio controls>
  <source src="./media/sound.aac" type="audio/aac" />
  <source src="./media/sound.mp3" type="audio/mp3" />
  <source src="./media/sound.wav" type="audio/wav" />
  <source src="./media/sound.ogg" type="audio/ogg" />
</audio>
  • There are lots of attributes that you can add to the <audio> element.
  • The autoplay attribute is now ignored by most browsers.
Last Updated: : 8/26/2019, 3:00:46 PM