You are here:

HTML/bacground sound

Advertisement


Question
I have looked for the Audio Tage like you told me to because it says it will play in most Browsers.

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

But one thing why is it giving me two codes in the middle for two diferant formats

  <source src="horse.mp3" type="audio/mpeg">
  <source src="horse.ogg" type="audio/ogg">

Does this meen if I have same sound file but if I make it in two diferant Formats one will be a Backup for someone that can only play one Format?

And 2. if I want it to AutoPlay but show no player do I do this

<audio auto start="yes" loop="2">
  <source src="horse.mp3" type="audio/mpeg">
  <source src="horse.ogg" type="audio/ogg">
  Your browser does not support this audio format.
</audio>

Answer
The browsers each play different formats, due to licensing and patents.  By putting in both file types, like you did above, it allows the browser to pick the one it can use.


You asked if the second code example is what you do.  Did you try it? If so, what happened?

HTML

All Answers


Answers by Expert:


Ask Experts

Volunteer


Dan Stephenson

Expertise

I am a professional Web Designer & Developer. I work with HTML, XHTML and CSS every day, and would be glad to help with your problems, and answer your questions.

Experience


Experience in the area I have been a web designer/developer since 1997. I started developing websites with HTML 3.2 and using tables for layout. In 2006 I received my degree in Computational Media, and now work full time as a Webmaster and Interactive Media Author, as well as teaching continuing education courses on HTML, CSS and ActionScripting at my local college. Currently I design with XHTML and CSS - no tables and much cleaner and more accessible code and allows the designer more freedom and flexibility than tables.

Education/Credentials
New Media Production & Design Degree - SAIT Polytechnic

©2016 About.com. All rights reserved.