How do I automatically play a Youtube video (IFrame API) muted?


<iframe class="youtube-player" type="text/html" src="" frameborder="0">&lt;br /&gt;</iframe>

The video isn't muted! I want volume to be 0 when it first plays...

This question is tagged with javascript jquery youtube

~ Asked on 2012-01-15 11:45:32

The Best Answer is


Youtube don't provide muting through url parameter (see

You have to use javascript for that. see for details.

However, please note the warning on the page linked above: "The deprecation of the YouTube JavaScript Player API was announced on January 27, 2015. YouTube Flash embeds have also been deprecated. See the deprecation policy for more information. Please migrate your applications to the IFrame API, which can intelligently use whichever embedded player – HTML () or Flash () – the client supports."


<iframe class="youtube-player" id="player" type="text/html" src="" frameborder="0">&lt;br /&gt;</iframe>

please note enablejsapi=1 in the url.


var player =  iframe.getElementById('player');


Previous code had some issues and did not work with current API (playerVars syntax was wrong). Here is the updated code. You may need to tinker with the parameters you need.

    <div id="player"></div>_x000D_
      // 1. This code loads the IFrame Player API code asynchronously._x000D_
      var tag = document.createElement('script');_x000D_
      tag.src = "";_x000D_
      var firstScriptTag = document.getElementsByTagName('script')[0];_x000D_
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);_x000D_
      // 2. This function creates an <iframe> (and YouTube player)_x000D_
      //    after the API code downloads._x000D_
      var player;_x000D_
      function onYouTubeIframeAPIReady() {_x000D_
        player = new YT.Player('player', {_x000D_
          height: '100%',_x000D_
          width: '100%',_x000D_
          playerVars: {_x000D_
                    autoplay: 1,_x000D_
                    loop: 1,_x000D_
                    controls: 0,_x000D_
                    showinfo: 0,_x000D_
                    autohide: 1,_x000D_
                    modestbranding: 1,_x000D_
                    vq: 'hd1080'},_x000D_
          videoId: '1pzWROvY7gY',_x000D_
          events: {_x000D_
            'onReady': onPlayerReady,_x000D_
            'onStateChange': onPlayerStateChange_x000D_
      // 3. The API will call this function when the video player is ready._x000D_
      function onPlayerReady(event) {_x000D_;_x000D_
      var done = false;_x000D_
      function onPlayerStateChange(event) {_x000D_
      function stopVideo() {_x000D_

~ Answered on 2012-01-15 12:04:39


Try this its working fine

<html><body style='margin:0px;padding:0px;'>_x000D_
        <script type='text/javascript' src=''></script><script type='text/javascript'>_x000D_
                var player;_x000D_
        function onYouTubeIframeAPIReady()_x000D_
        {player=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}_x000D_
        function onPlayerReady(event){player.mute();player.setVolume(0);player.playVideo();}_x000D_
        <iframe id='playerId' type='text/html' width='1280' height='720'_x000D_
        src='' frameborder='0'>_x000D_

~ Answered on 2016-09-12 10:13:49

Most Viewed Questions: