Skip to content

Instantly share code, notes, and snippets.

@theodorocaliari
Last active December 23, 2015 00:29
Show Gist options
  • Save theodorocaliari/6554342 to your computer and use it in GitHub Desktop.
Save theodorocaliari/6554342 to your computer and use it in GitHub Desktop.
Play YouTube Video Muted
<!doctype html>
<html>
<body>
<div id="ytplayer"></div>
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
width: '330',
height: '230',
videoId: 'jofNR_WkoCE',
playerVars: {
'wmode': 'opaque',
'autoplay': 1,
'controls': 0 ,
'showinfo': 0,
//'start': 20,
'rel': 0,
'loop': 1,
},
events:{
'onReady':onPlayerReady
}
});
}
function onPlayerReady(event) {
event.target.mute();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment