Is there a way to mute the audio of an iframe using jQuery or CSS?
This is the iframe I need to mute
Here you are with a button based on previous answers http://jsfiddle.net/qumg6e7h/
$('button').on('click', function () {
var iframe = $(this).prev('iframe')[0];
if ($(this).hasClass('mute')) {
$(this).removeClass('mute').text('Mute');
iframe.contentWindow.postMessage('{"method":"setVolume", "value":1}', '*');
} else {
$(this).addClass('mute').text('Unmute');
iframe.contentWindow.postMessage('{"method":"setVolume", "value":0}', '*');
}
});
You can have as many iframes as you like. Just add the button after the iframe and on click mute/unmute the video :)