Created
May 18, 2012 21:17
-
-
Save buzzedword/2727642 to your computer and use it in GitHub Desktop.
Youtube player snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var player = function(selector, dimensions) { | |
| var $yt = $(selector); | |
| $yt.each(function() { | |
| var $this = $(this); | |
| var _data = $this.data(); | |
| var params = { | |
| allowScriptAccess: "always", | |
| wmode: 'opaque', | |
| controls: 0, | |
| rel: 0, | |
| showinfo: 0, | |
| modestbranding: 1 | |
| } | |
| var atts = { | |
| id: [$this.attr('id'), '-', 'generated'].join('') | |
| }; | |
| var flashVars = { | |
| wmode: 'opaque' | |
| }; | |
| // API call for SWF object. Broken into array joins to make sense of each block. | |
| swfobject.embedSWF(['http://www.youtube.com/v/', _data.youtubeId, // Extracted from data stored in DOM for video post. | |
| '?', ['enablejsapi=1', // Enables JS api. | |
| ['playerapiid=ytplayer-', $this.attr('id')].join(''), // Sets the API ID. | |
| 'version=3', // API version 3. | |
| 'rel=0', 'modestbranding=1', 'controls=0', 'showinfo=0'].join('&'), ].join(''), $this.attr('id'), // Use the ID of the currently looped container | |
| dimensions.x, // Set the width | |
| dimensions.y, // Set the height | |
| "8", // Flash version | |
| null, flashVars, params, atts); | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment