WWW FAQs: How do I play embedded sounds at a specific volume?


2006-12-22: If you are following my recommendation and using the free Flash-based XSPF Web Music Player, this is easy to do. Just set the volume_level parameter when embedding the Flash player:


<object type="application/x-shockwave-flash" width="400" height="170"
data="xspf_player.swf?playlist_url=test.xspf&volume_level=50">
<param name="movie" value="xspf_player.swf?playlist_url=test.xspf&volume_level=50" />
</object>

Here I have set the volume to 50% (50). Notice that you must set volume_level in both the data attribute and the param element. Otherwise behavior will not be consistent from browser to browser.

For Flash Haters

If, for whatever reason, you refuse to use Flash on your website, you probably need this feature even more, because you don't have any control over what the default volume level of the embedded player might be. You can address this by setting the volume attribute of the <embed> element to 100 (meaning 100%), like this:


<embed src="mymusic.mp3"
  volume="100"
  height="60"
  width="145"
  autostart="true"
  width="0"
  height="0">
</embed>

Some embedded players might not respect the volume attribute. If you don't like this lack of control, use Flash.

For more information, see How do I embed sound and music in a page?

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!