Advertisement
Guest User

Youtube Autoplay

a guest
Jan 29th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.99 KB | None | 0 0
  1. <!-- 1. The <div> tag will contain the <iframe> (and video player) -->
  2.     <div id="player"></div>
  3. <script>      // 2. This code loads the IFrame Player API code asynchronously.
  4.       var tag = document.createElement('script');
  5.       tag.src = "http://www.youtube.com/player_api";
  6.       var firstScriptTag = document.getElementsByTagName('script')[0];
  7.       firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  8.  
  9.       // 3. This function creates an <iframe> (and YouTube player)
  10.       //    after the API code downloads.
  11.       var player;
  12.       function onYouTubePlayerAPIReady() {
  13.         player = new YT.Player('player', {
  14.           playerVars: { 'autoplay': 1, 'controls': 1,'autohide':1,'wmode':'opaque' },
  15.           videoId: 'JW5meKfy3fY',
  16.           events: {
  17.             'onReady': onPlayerReady}
  18.         });
  19.       }
  20.  
  21.       // 4. The API will call this function when the video player is ready.
  22.       function onPlayerReady(event) {
  23.         event.target.mute();
  24.       }
  25. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement