Norbert
Norbert

Reputation: 2771

Custom Mute Button for Audio Embedding?

I'm trying to set up a custom mute button for the embed tag.

<embed src="intro.mp3" autostart="true" hidden="true" loop="false">

Is there a way to do this via JS?

This worked for the audio tag:

document.getElementById('audio').muted = true;

Upvotes: 2

Views: 1394

Answers (2)

deebs
deebs

Reputation: 1410

This is obviously an old question, but I had a similar issue... probably not the best solution, but I just placed the embed in a div and removed that div on the 'mutebutton' click, then hid the mute button:

<a href="#" id="mutebutton">mute</a>

<div id="soundDiv"><embed...></embed></div>

$("#mutebutton").click(function() {
            $(this).hide();
            var div = document.getElementById("soundDiv");
            div.parentNode.removeChild(div);
        });

I'm still a noob, so this may not work for you. But it did for me!

Upvotes: 0

nwellcome
nwellcome

Reputation: 2299

Nope, there is no muted attribute for embed elements. If you want control over the volume you'll need to use the audio element or a proprietary plugin that you can pass parameters to.

Upvotes: 2

Related Questions