Knowledge base
Knowledge base
Knowledge base
 
Programmazione - HTML
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>

<script type='text/javascript'>
    var player;
    function onYouTubeIframeAPIReady(){
player=new YT.Player('playerId',{events:{onReady:onPlayerReady}})
}
function onPlayerReady(event){
player.mute();player.setVolume(0);player.playVideo();
}
</script>
<iframe id='playerId' type='text/html' width='1280' height='720' src='https://www.youtube.com/embed/IL_CODICE_DEL_TUO_VIDEO?enablejsapi=1&rel=0&playsinline=1&autoplay=1&showinfo=0&autohide=1&controls=0&modestbranding=1' frameborder='0'>

 

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>

 

 
COMPUTER PLUS srl
Via Fernando Santi 5
60035 JESI (AN)
Tel. 0731 214634
Fax 0731 221903
info@computerplus.it
info@pec.computerplus.it
Chi Siamo
Dove Siamo
Lo Staff
Contatti
Company Profile
Richiesta assistenza
Supporto
 
Effettua i tuoi pagamenti online!
È facile e veloce!
 
Inoltre puoi utilizzare anche il nostro POS virtuale per pagare anticipi o fatture ⇨ pos.computerplus.it
© Copyright 2024 Computer Plus srl | P.Iva IT01538200427 | Termini e Condizioni> | Politica sulla privacy | Informativa sui cookies