Quantcast
Channel: Eureka! » HTML5
Viewing all articles
Browse latest Browse all 12

HTML5 – Play sound/music with tag @ 1

$
0
0

Next: HTML5 – Play sound/music with <audio> tag @ 2

With HTML5, we can easily play audio file with the <audio> tag. Here is an example.

<html>
  <head></head>
  <body>
    <audio controls loop autoplay>
      <source src="music.ogg" type="audio/ogg" />
      <source src="music.mp3" type="audio/mp3" />
      Your browser does not support the audio element.
    </audio> 
  </body>
</html>


 

A control panel will be shown when the HTML is rendered.

 

Please note that you have to include both .ogg and .mp3 because .ogg works in Firefox, Opera and Chrome while .mp3 is for Internet Explorer and Safari.

Done =)

Reference:


Filed under: HTML5 Tagged: Chrome, Firefox, HTML5, Internet Explorer, Opera, Safari

Viewing all articles
Browse latest Browse all 12

Trending Articles