how do i program the youtube embed player to unmute when clicked

前端 未结 3 1508
囚心锁ツ
囚心锁ツ 2021-01-19 14:18

How do I set the youtube embedded player to unmute upon clicking it. You can see the embedded player i\'m referring to at http://www.harvestarmy.org home page. It\'s the one

3条回答
  •  独厮守ぢ
    2021-01-19 14:22

    This works. But unfortunately the pause icon fades in when the video is clicked. Even the video continues to run it is not a clean solution. I fixed it by placing a

    with exactly the same size above the actual video iframe and use its click() function to unmute the video.

    HTML:

      

    CSS:

    .video-container {
      position: relative;
      width: 640px;
      height: 390px;
    }
    
    .video-dummy {
      width: 640px; 
      height: 390px;
      position: absolute;
    }
    

    Javascript:

    $('.video-dummy').click(function(){
      player.unMute();
    });
    

    This works out well for me.

提交回复
热议问题