First post of the year and let’s start with something really cool.

Using PHP with Javascript and FLV players is not a big news on the market, but Google Code Project, SWFObject make it a new standart.

I bet that any deleveloper have done some ugly Javascript coding to print out the embed object on the page document. It have been so far the most easy and cross-browser reliable way to dinamically create flash embed objects on the page document. Google Code Project, SWFObject, creates a new way to construct this embed objects and an even better way to control the parameters, flash variables, attributes, etc.

The triad of PHP, Javascript and FLV players would come in way that PHP would stream the video content, guaranting more security, Javascript would grab the information, create the embed object and sent it to the FLV player to play the stream. You got love that. It’s a great and realiable way to stream flash content on your users browsers.

How would be the coding for the SWFObject? Simple:

<script type=”text/javascript” src=”swfobject.js”></script>
<script type=”text/javascript”>
var flashvars = {};
flashvars.src = “myPHPSCRipt.php”;
var params = {};
params.play = “true”;
params.loop = “false”;
params.menu = “false”;
params.quality = “autohigh”;
params.wmode = “transparent”;
params.devicefont = “false”;
params.swliveconnect = “false”;
params.allowfullscreen = “true”;
params.allowscriptaccess = “sameDomain”;
params.allownetworking = “none”;
var attributes = {};
attributes.id = “theFlashPlayerID”;
attributes.name = “theFlashPlayerID”;
attributes.align = “left”;
swfobject.embedSWF(“player.swf”, “theDivID”, “320”, “240”, “9.0.0”, “expressInstall.swf”, flashvars, params, attributes);

Simple and clean coding.

Add you flash player on the same location as the SWFOjbect (or correctly reference it) and add a div with the id = “theDivID” (or whatever ID you want for it) and you will have everything working (the SWFObject will replace the div with the embed code).

For more information about it and for much more resources here are some great places to start at:


About mcloide

Making things simpler, just check: http://www.mcloide.com View all posts by mcloide

2 responses to “SWFObject

  • johngills

    There is another reason that you would want to use Google’s SWFObject for overcoming the “click to load” problem with EMBED flash elements in IE is indexing.

    You may remember back in June, Adobe provided Google with an indexing solution for Googlebot. (http://googlewebmastercentral.blogspot.com/2008/06/improved-flash-indexing.html) Now, Google can crawl flash files looking for text that would help index the content on those files. However, it’s a well know fact that Googlebot is limited in its abilty to parse javascript. Google has stated that they will support SWFObject for locating and indexing flash files. If you use some other solution, you are probably giving up your chances of any context in your flash being indexed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: