Youtube Video w/ Javascript API - Autoplay & Muted


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script src="http://www.google.com/jsapi"></script>
  2. <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
  3. <div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>
  4. <script type="text/javascript">
  5. google.load("swfobject", "2.1");
  6. function onYouTubePlayerReady(playerId) {
  7. ytplayer = document.getElementById("myytplayer");
  8. ytplayer.playVideo();
  9. ytplayer.mute();
  10. }
  11. var params = { allowScriptAccess: "always" };
  12. var atts = { id: "myytplayer" };
  13. swfobject.embedSWF("http://www.youtube.com/v/J2hqhNhAj_g?enablejsapi=1&playerapiid=ytplayer&allowFullScreen=true&version=3",
  14. "ytapiplayer", "425", "356", "8", null, null, params, atts);
  15. </script>

URL: http://www.faisalkaleem.com/api/how-to-autoplay-a-youtube-video-in-mute-using-js-api.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.