EMBEDDING A FLASH FILE (SWF)
Any Flash Application
- Embedding an audio file (played in WMP)
- Embedding a video file (played in WMP)
- Embedding a Quicktime player (mov, qtl, mp4 files)
Here I will show 2 solutions, both good, both valid.
Here is the original code snippet that works in all browsers, except as noted below about MSIE. It's entirely based on the Satay Flash method.
NB: This code is for a document with an XHTML doctype. For an HTML doctype or no doctype at all, ALL tags that are closed with a /> MUST be closed with only a >.
<object width="500" height="200" data="flash-file.swf" type="application/x-shockwave-flash" title="Title of this flash object"> <param name="movie" value="flash-file.swf" /> <param name="height" value="200" /> <param name="width" value="500" /> <param name="menu" value="false" /> <param name="quality" value="autohigh" /> <!-- remove the wmode if transparency is not needed --> <param name="wmode" value="transparent" /> <em>Description of this flash object</em> </object>
An example of Flash file embedded in this manner:
In the above example the assumption is that the necessary plugin is installed in the browser. That in itself is a challenge in all browsers other than IE, but that is a different problem.
An update in May 2006 in the way Microsoft IE6 handled the object and embed tags brought about a very annoying phenomenon which required an additional click to activate the control (for any type of embedded object: Macromedia Flash, Windows Media Player, Real Player, Quicktime, Java applets, PDF files).
This problem has been corrected subsequently by MS, but the methods described here remain valid.
After trying and discarding several workarounds that had been proposed, all of which I found unacceptable due to their high complexity of implementation and lack of flexibility, the solution that appears below is the best and most elegant of all. It comes from Geoff Stearns of http://www.deconcept.com/ and is documented at http://blog.deconcept.com/swfobject/.
It actually affords an ideal way to provide alternate content for Flash, in adition of getting rid of the MSIE annoying message (at the time it applied) and of course using w3 valid code.
And yes, this also allows embedding videos from YouTube or other similar sources like Google Video or MySpace Video. All you need is to adapt the code given by the video hoster and use the method given here. In fact you only need 3 parameters: the url of the video and its display dimensions.
But please note that this version I've been using is now old, though it has served me well and it will continue to serve well for simpler, uncomplicated flash needs. A new and much more sophisticated version is available from the official SWFObject Google Code Download site with support at the Google SWFObject Group.
Two scripts are to be included in the head section of the web page: SWFObject.js and mySWFmovie.js. Both are available for download as a zip file here.
Right after closing this div, place another simple script which will serve to insert the flash movie object.
Here is an example using SWFObject which has been coded exactly this way.
NB: These scripts are a work in progress. Please revisit this site in order to find the latest versions. Also please let me know of any limitations or bugs you may have found, whether concerning differnt operating systems or browsers than what I have been able to test myself.