bestbuildpc: Forums
 

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HTML5 Audio
 
 
Post new topic   Reply to topic    bestbuildpc Forum Index -> Web Development
View previous topic :: View next topic  
Author Message
bestbuildpc
Site Admin
Site Admin


Joined: Jun 30, 2012
Posts: 213
Location: NL

PostPosted: Mon Sep 23, 2013 9:34    Post subject: HTML5 Audio Reply with quote

Audio on the Web

Until now, there has not been a standard for playing audio files on a web page.

Today, most audio files are played through a plug-in (like flash). However, different browsers may have different plug-ins.

HTML5 defines a new element which specifies a standard way to embed an audio file on a web page: the <audio> element.

Browser Support

Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the <audio> element.

Note: Internet Explorer 8 and earlier versions, do not support the <audio> element.

HTML5 Audio - How It Works

To play an audio file in HTML5, this is all you need:


Code:
<!DOCTYPE html>

<html>
<body>

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

</body>
</html>


The control attribute adds audio controls, like play, pause, and volume.

You should also insert text content between the <audio> and </audio> tags for browsers that do not support the <audio> element.

The <audio> element allows multiple <source> elements. <source> elements can link to different audio files. The browser will use the first recognized format.


  
Back to top
View user's profile Send private message Visit poster's website
bestbuildpc
Site Admin
Site Admin


Joined: Jun 30, 2012
Posts: 213
Location: NL

PostPosted: Mon Sep 23, 2013 10:11    Post subject: Reply with quote

If you would like to play your music automatically then use this one:

Code:
<!DOCTYPE html>

<html>
<body>

<audio loop="loop" autoplay="autoplay" controls="controls">
  <source src="bumbum.ogg" type="audio/ogg">
  <source src="bumbum.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

</body>
</html>


If you wanna play the music by yourself then use this one:

Code:
<!DOCTYPE html>

<html>
<body>

<audio loop="loop" controls="controls">
  <source src="bumbum.ogg" type="audio/ogg">
  <source src="bumbum.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

</body>
</html>


That's all folks!
  
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    bestbuildpc Forum Index -> Web Development All times are GMT + 2 Hours
 
 Page 1 of 1

 

Jump to:   
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001-2008 phpBB Group
 
Forums ©