ricoramiro2

Embed YouTube Video Muted

Sep 18th, 2017
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.55 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <meta name="viewport" content="width=device-width">
  6.     <title>Embed YouTube Video Muted</title>
  7.   </head>
  8.   <body>
  9.     <div style="margin:20px auto;width:600px">
  10.       <p>The YouTube video on this page will automatically play but muted.</p>
  11.       <p>See tutorial: <a href="http://www.labnol.org/?p=29149">Embed YouTube Video Muted</a>
  12.       <div id="muteYouTubeVideoPlayer"></div>
  13.     </div>
  14.  
  15.     <script async src="https://www.youtube.com/iframe_api"></script>
  16.     <script>
  17.       function onYouTubeIframeAPIReady() {
  18.         var player;
  19.         player = new YT.Player('muteYouTubeVideoPlayer', {
  20.           videoId: '-hX_rznqnM0', // YouTube Video ID
  21.           width: 560,             // Player width (in px)
  22.           height: 316,            // Player height (in px)
  23.           playerVars: {
  24.             autoplay: 1,        // Auto-play the video on load
  25.             controls: 1,        // Show pause/play buttons in player
  26.             showinfo: 0,        // Hide the video title
  27.             modestbranding: 1,  // Hide the Youtube Logo
  28.             loop: 1,            // Run the video in a loop
  29.             fs: 0,              // Hide the full screen button
  30.             cc_load_policty: 0, // Hide closed captions
  31.             iv_load_policy: 3,  // Hide the Video Annotations
  32.             autohide: 0         // Hide video controls when playing
  33.           },
  34.           events: {
  35.             onReady: function(e) {
  36.               e.target.mute();
  37.             }
  38.           }
  39.         });
  40.       }
  41.     </script>
  42.   </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment