youtube - trick to loop youtube video with youtube API for admanager

0 votes
298 views
added Jun 24, 2021 in Google tools by lcjr First Warrant Officer (11,780 points)
<!DOCTYPE html>
<html>
    <head>
      <script type="text/javascript">
      // Change the value of this string to your URL
        var clickTag = "https://www.youtube.com/watch?v=PEwac2WZ7rU";
      </script>
    </head>
    <body style="margin: 0px;"> 
      <a href="javascript:window.open(window.clickTag)"> 
      <div id="player"></div>
      <div id="player2"></div>
      </a>

      <script>
        var tag = document.createElement('script');
  
        tag.src = "https://www.youtube.com/iframe_api";
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
        var player, player2;
        
        
        function onYouTubeIframeAPIReady() {
          player = new YT.Player('player', {
            height: '250',
            width: '300',
            videoId: 'PEwac2WZ7rU',
                  playerVars: {
                    start: 1,
                    end: 182,
                    loop: 1,
                    playlist: 'PEwac2WZ7rU',
                    rel: '0',
                    iv_load_policy: '3'
                  },
            events: {
              'onReady': onPlayerReady,
              'onStateChange': onPlayerStateChange
            }
          });
          
        }
  
        function onPlayerReady(event) {
          event.target.playVideo();
          event.target.mute();
        }
  
        function onPlayerStateChange(event) {
        }
  
      </script> 
    </body>   
 
</html>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...