Stream Flash SWF's using VALID XHTML on Firefox and IE 6, 7 & 8

Published


Today I needed to steam a Flash .SWF file to Firefox, IE 7 (plus 6 and 8 on occasions) using valid XHTML. No big deal you should say, but actually it is.  The valid XHTML most developers suggest is as follows:

    <object type="application/x-shockwave-flash" data="MyStreamingVideoUrl.swf" style="width:640px; height:520px">
         <param name="loop" value="false" />
         <param name="menu" value="false" />
     </object>

Yes, this allows the video to play in Firefox and IE, but, it disables streaming on Win/IE browsers!  That's right, the poor IE users have to wait until my 100MB production has downloaded to their machines before it will appear!

In amongst my research for a solution I found many hideous solutions including using conditional HTML statements...

 <!--[if IE]>
 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="640" height="520">
     <param name="movie" value="MyStreamingVideoUrl.swf" />
 <![endif]-->
 <!--[if !IE]>
     <object type="application/x-shockwave-flash" data="MyStreamingVideoUrl.swf" style="width:640px; height:520px">
 <![endif]-->
     <param name="loop" value="true" />
     <param name="menu" value="false" />
 </object>

And unsurprisingly, none of these worked across all versions of IE.  So, by pure chance I found the solution...

Steam Flash SWF's to Firefox and IE 6,7,8 using valid XHTML

The solution is incredibly simply, and involves and extra line of code to account for IE's lack of modernisation.  Here is the working, valid XHTML in all its glory:

    <object type="application/x-shockwave-flash" data="MyStreamingVideoUrl.swf" style="width:640px; height:520px">
         <param name="movie" value="MyStreamingVideoUrl.swf" />
         <param name="loop" value="false" />
         <param name="menu" value="false" />
     </object>

That's it.  To get IE to stream the video rather than download it, we just reference the movie file again in the second line's <param> line.   No hacks, no Javascript, no conditional statements - just clean valid XHTML!

To prove the point, just copy and paste the following into the W3C's Validator and check the result:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 <title>
     My Streaming Flash SWF using valid XHTML
 </title>
 </head>
 <body>
 <div>
     <object type="application/x-shockwave-flash" data="MyStreamingVideoUrl.swf" style="width:640px; height:520px">
         <param name="movie" value="MyStreamingVideoUrl.swf" />
         <param name="loop" value="false" />
         <param name="menu" value="false" />
     </object>
 </div>
 </body>
 </html>

Comments

No comments have been posted. Be the first to write a comment...

New Comment





This is to prove that you are not a spam robot posting links to dodgy sites!