HyperText Markup Language/Music

From Wikibooks, open books for an open world
< HyperText Markup Language
Jump to: navigation, search

Users should have control over the background sound or music; therefore, media player controls should always be visible. Don't try to script your own controls since they might not work in all environments.

One valid way to do an autostarting (background) music player is to use Windows Media Player ActiveX for IE. Other browsers like Firefox, Opera and Safari can use a generic solution which doesn't dictate what plugin should be used. Plugin can be, for example, QuickTime (Windows, Mac) or MPlayer (GNU/Linux). If a suitable player doesn't exist, then fall back to a plain link.

-Copy the following code to your site
-Replace all four occurrences of "clip.mp3" with correct filename
Other widely supported file formats are midi and wav, if you use those remember to change the type attribute accordingly:
audio/midi for midi files
audio/x-wav for wav files

<!--[if IE]>
<object id="player" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="288" height="69">
  <param name="URL" value="clip.mp3">
<!--[if!IE]> <-->
<object id="player" type="audio/mpeg" data="clip.mp3" width="288" height="69">
  <param name="src" value="clip.mp3">
  <a href="clip.mp3">Play background music artist - title [MP3]</a>
<!--> <![endif]-->