Announcement

Collapse
No announcement yet.

YouTube Videos autoplay and *muted*

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • YouTube Videos autoplay and *muted*

    After searching the web far & wide, I found a code to embed YouTube videos that will autoplay *AND* be muted. The auto-mute is the most exciting part. I didn't want to blast people with sound unless they chose it. I use this in at the top of my right side banner, to introduce people to stunt kiting, as many haven't seen it before.

    Just add your movie code in the area that says 'YOURMOVIECODEHERE'. The code is at the end of the address in YouTube, for example,

    http://www.youtube.com/watch?v=3T8a_makxig

    The specific code for this movie is everything after the "=", 3T8a_makxig


    Code:
    <script src="http://www.google.com/jsapi"></script>
    	<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
    	<div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>
    	<script type="text/javascript">
    	    google.load("swfobject", "2.1");
    	    function onYouTubePlayerReady(playerId) {
    	        ytplayer = document.getElementById("myytplayer");
    	        ytplayer.playVideo();
    	        ytplayer.mute();
            	    }
    	    var params = { allowScriptAccess: "always" };
    	    var atts = { id: "myytplayer" };
    	    swfobject.embedSWF("http://www.youtube.com/v/YOURMOVIECODEHERE?enablejsapi=1&playerapiid=ytplayer&allowFullScreen=true&version=3",
    	    "ytapiplayer", "160", "160", "8", null, null, params, atts)
    	</script>
    :p
    Last edited by vkmcewen; 03-22-2011, 12:26 PM. Reason: explain my placement of code
    VMcEwen
    Zephyr Kites
Working...
X