In my post about embedding video content in (X)HTML this morning, I mentioned that I didn’t know the correct codebase attribute to use when embedding Flash video clips from online resources in my web pages… well, now I do!
It seems that every Flash (.SWF) file includes a header which includes the Flash version number in the 4th byte.
OK… great… but how do I view the header?
First, I found a forum thread discussing a method for testing the minimum version of Flash player is required to display a .SWF. however, trying to write some ActionScript in MX Studio 2004 blew my mind (I don’t know anything about Flash development). A bit more googling led to another thread on .SWF header-only parsing, including some Java code (unfortunately I don’t know how to use a Java class either!).
Now what? Realising that I’m an operating-system-and-infrastructure-kind-of-guy and not a programmer, I started to think about the command line… what if I get hold of a .SWF file and type head filename.swf
? Lots of beeps and unintelligible ASCII characters, that’s what! Hang on… that started with CWS? Flash file headers always begin with CWS or FWS… getting warmer… how can I read that 4th byte… think back to hacking school computers with the MS-DOS debugger 20 years ago… think hexadecimal… a hex editor – that’s the answer!
As I was working on Mac (i.e. no debug.exe available), I needed to download a free hex editor. HexEdit looked like it should do the trick but there is not a universal binary version available yet (only 68000 and PowerPC). Then I found a link to 0xED (nice name for a hex editor guys!) on the Apple development tools download site. I opened a .SWF file and… 43 (C)… 57 (W) … 53 (S)… 07… Flash Player 7 required. Sorted. Repeating for a few more files, I found FWS4 and FWS5… this was looking good, now what about the iFilm and YouTube links in my post this morning? As they don’t expose the content directly (even when you dig about in the HTML), I thought of using something like TubeSock to rip the content but realised that wouldn’t help in this case as it also performs a file format conversion. Then I noticed that the websites use their own Flash players to access the video content – 0xED can also open by path – and after entering the required URL (http://www.ifilm.com/efp or http://youtube.com/player2.swf), I found the information I needed – YouTube content needs Flash Player 7 or later and iFilm content needs Flash Player 8 or later.
Now I can go back and edit those codebase attributes to the correct minimum player version!
Yeah, good old trick with hex editor. I can reccomand you fiddler it is very useful when you load many swf files, to check are they all published in same version.