WWW FAQs: How do I embed music or video with the sound muted?

2006-12-22: I recommend the use of the free FlowPlayer Flash-based video player in my article how do I add video to my website? Unfortunately, while this is a great solution in most ways, FlowPlayer doesn't currently support specifying a volume level. So you can't mute the audio in a video played in this way. If muting is crucial for you and you still want the control offered by a Flash-based player, consider the XSPF Free Music Player (as enhanced by Lacy Morrow and myself), which supports Flash FLV video in addition to audio and has a volume_level parameter.

If you are embedding video the old-fashioned way, by embedding it directly with the embed element and allowing the web browser to choose the user's preferred video player, then you can mute the sound using the volume attribute of the <embed> element. Set it to 0 (meaning 0%), like this:

<embed src="myvideo.avi" volume="0" height="320" width="280" autostart="true"/>

Not every player will necessarily respect this, and users who really want to will find ways around it, so if it's crucial that no one hear it, you should strip the sound out of your video file with a video editor before uploading it.

Yes, you can use the same technique with audio files. Or, if you are using my recommended audio solution, the Flash-based XSPF Free Music Player, you can control the volume level with parameters passed to Flash. See how do I play embedded sounds at a specific volume?

For more information, see How do I add video to my website?

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!