YouTube: How to present embed video with sound muted
Updated
Add &mute=1
to the end of your url.
Your new code would be:
<iframe src="https://www.youtube.com/embed/uNRGWVJ10gQ?rel=0&autoplay=1&mute=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>
How do I toggle video mute in an iframe ( youtube ) with a button?
It's work for me, Thanks!
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('wp-custom-header-video', {
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady() {
console.log("hey Im ready");
//do whatever you want here. Like, player.playVideo();
}
function onPlayerStateChange() {
console.log("my state changed");
}
document.getElementById("mute").addEventListener('click', function(event) {
console.log(player);
if (player.isMuted()) {
player.unMute();
} else {
player.mute();
}
});
#mute {
cursor:pointer;
padding: 10px 20px;
background:#000;
color: #fff;
border-radius: 4px;
display: inline-block;
}
<p>
<button id="mute">Mute/UnMute</button>
</p>
<iframe id="wp-custom-header-video" name="video-wp" frameborder="0" allowfullscreen="1" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" title="YouTube video player" width="600" height="400" src="https://www.youtube.com/embed/4vGzJ3nTzp4?autoplay=1&controls=0&disablekb=1&fs=0&iv_load_policy=3&loop=1&modestbranding=1&playsinline=1&rel=0&showinfo=0&enablejsapi=1&widgetid=1;origin=https%3A%2F%2Fepistolariodelamemoria.cl&" data-gtm-yt-inspected-1_19="true" data-initial-width="2000" data-initial-height="1200"></iframe>
Related Topics
CSS Transition - Eases in But Doesn't Ease Out
CSS Image Resize Percentage of Itself
How to Stretch Flex Child to Fill Height of the Container
Right Align an Image Using CSS HTML
Flexbox: Wrong Width Calculation When Flex-Direction: Column, Flex-Wrap: Wrap
Center HTML Input Text Field Placeholder
Html:How to Show Images in a Textarea
Form and File Upload with HTMLservice and App Script Not Working
Height Percentage Not Working in CSS
Is Using <Li> Without Enclosing <Ul> Tags Dangerous
With a Browser, How to Know Which Decimal Separator Does the Operating System Use
Set Height 100% on Absolute Div
How to Notify the HTML Container That the Swf Has Finished, Using Swfobject
Table Scroll with HTML and CSS
Is the HTML Shown via 'View Source' Different from the HTML Shown in (Firebug) Developer Tools