iPhone Flash Workaround (Static Replacement)
Recently, I was putting the finishing touches on a website design for a good client who wanted something flashy, something eye-catching, so I put together a very typical piece of Flash with photos, smooth transitions, quick phrases, and so forth. Trouble is, the first time Boss-man checked out the design, he did so on his iPhone. So rather than a pretty animation, he saw an ugly blue box requesting he acquire Flash software (which isn’t available on iPhone [yet?]).
The customer is always right, so when Boss-man wanted it to look good on his iPhone, I called up the smartest PHP-er I know… docere. Enough blathering aside, here’s a code snippet to show you how to insert a static image of your choice in place of the “Missing Flash Plugin” placeholder for iPhone.
Here’s the original code for displaying my piece of flash:
<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=’760′ HEIGHT=’130′ id=’wipe.swf’ ALIGN=”>
<PARAM NAME=movie VALUE=’wipe.swf’> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src=’wipe.swf’ quality=high bgcolor=#000000 WIDTH=’760′ HEIGHT=’130′ NAME=’wipe.swf’ ALIGN=” TYPE=’application/x-shockwave-flash’ PLUGINSPAGE=’http://www.macromedia.com/go/getflashplayer’></EMBED> </OBJECT>
Here’s the envelope to check what type of browser is viewing the image and to redirect iPhones to a static image (using the PHP if and strpos function to parse $_SERVER['HTTP_USER_AGENT']).
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'],”iPhone“) {
// static image
} else {
// flash file for everyone else
}
?>
To get a better feel for how this works, click here!< Here’s the simple code being ran, server-side.
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
Good information can be determined from your visitor’s browser/OS, allowing you to customize the design to accomodate any… less-than-ideal browser traits (bugs). This really opens up a potential new world of designing the same site multiple times to appear just right on each of many different browsers… you know, if you’re feeling masochistic.
For all you completionists out there, here’s what the final snippet of PHP turned out to be:
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'],”iPhone”)) {
print “<div class=’Visual’><img src=’images/iphone_filler.jpg’></div>”;
} else {
print “<div class=’Visual’><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=’760′ HEIGHT=’130′ id=’wipe.swf’ ALIGN=”>
<PARAM NAME=movie VALUE=’wipe.swf’> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src=’wipe.swf’ quality=high bgcolor=#000000 WIDTH=’760′ HEIGHT=’130′ NAME=’wipe.swf’ ALIGN=” TYPE=’application/x-shockwave-flash’ PLUGINSPAGE=’http://www.macromedia.com/go/getflashplayer’></EMBED> </OBJECT></div>”;
}
?>
- The Dude
- P.S. - Apple, I want to access HULU on my iPhone, yah Cork Soakers
Tags: apple, Flash, iPhone, PHP, strpos
