I try to embed a youtube video on a website and mute it.
I have already find this subject: How do you mute an embedded Youtube player?
So I have try the answer and it's work: https://jsfiddle.net/Jonathan_Ironman/BFDKS/9/
But when I try the same code outside of jsfiddle, the javascipt code is not execute anymore.
Source Code
<html>
<head>
<script type="text/javascript">
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady()
{
player = new YT.Player('ytplayer',
{
events:
{
'onReady': onPlayerReady
}
});
}
function onPlayerReady()
{
player.playVideo();
// Mute!
player.mute();
}
</script>
<iframe id="ytplayer" type="text/html" style="position:absolute; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:0;" src="https://www.youtube-nocookie.com/embed/DjxwLr6TjHs?playlist=DjxwLr6TjHs&enablejsapi=1&border=0&start=60&autoplay=1&showinfo=0&controls=0&disablekb=1&cc_load_policy=1&iv_load_policy=3&rel=0&loop=1" frameborder="0"></iframe>
</head>
<body>
</body>
</html>
Any idea?