Enable fullscreen mode when generating YouTube movie with swfobject

I recently dived into the YouTube javascript API as we (the company I work for) wanted to track behaviour on the video (note that the YouTube javascript API is not great for this task, but that is another matter).

However, we encountered a strange issue where the fullscreen button was greyed out and was not clickable despite we included the fs=1 parameter in the embed URL.

The fix is simple, but subtle. You remember how the embed codes included those <param> tags that did some magical work which you never cared to remember? When I used an example found on the YouTube API reference they did not include the fullscreen parameter required to make fullscreen mode work.

Example (for a full working example see the code at the YouTube javascript API page):

From the example below you can see we must add the allowFullScreen parameter to the parameter list. This should enable you to view the video in fullscreen.

(function() {
 var params = { allowScriptAccess: "always", <strong>allowFullScreen: "true"</strong> },
 atts = { id: "myid" };

 "ytapiplayer", "340", "191", "8", null, null, params, atts);

This entry was posted in Programming, YouTube and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.