Come visualizzare un video YouTube embeded senza audio
Fra i parametri utilzzabili non c'è il mute quando si manda in autoplay un video.
In questo caso ci vengono in contro le API di YouTube.
Di seguito due sistemi in base al tipo di incorporamento.
1)<iframe>
<script type='text/javascript' src='http://www.youtube.com/iframe_api'></script>
|
2)<div>
<div id="muteYouTubeVideo"></div>
<script async src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('muteYouTubeVideo', {
videoId: 'IL_CODICE_DEL TUO_VIDEO', // YouTube Video ID
width: 560, // Player width (in px)
height: 316, // Player height (in px)
playerVars: {
autoplay: 1, // Auto-play the video on load
controls: 1, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // Hide the Youtube Logo
loop: 1, // Run the video in a loop
fs: 0, // Hide the full screen button
cc_load_policy: 0, // Hide closed captions
iv_load_policy: 3, // Hide the Video Annotations
autohide: 0 // Hide video controls when playing
},
events: {
onReady: function(e) {
e.target.mute();
}
}
});
}
</script>
|