Page 1 of 1

Check for Flash

Posted: Wed Apr 13, 2005 6:12 am
by Per
I was wondering if any of you has a nice little PHP code that checks if Flash is installed on visitors PC? Something like if flash do this, else do that...

Thanks in advance!

Posted: Wed Apr 13, 2005 6:42 am
by neophyte
Well here's what flash uses:

Code: Select all

<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes&#1111;&quote;application/x-shockwave-flash&quote;]) ? navigator.mimeTypes&#1111;&quote;application/x-shockwave-flash&quote;].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins&#1111;&quote;Shockwave Flash&quote;].description.split(&quote; &quote;);
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words&#1111;i])))
		continue;
		var MM_PluginVersion = words&#1111;i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf(&quote;MSIE&quote;)>=0 
   && (navigator.appVersion.indexOf(&quote;Win&quote;) != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject(&quote;ShockwaveFlash.ShockwaveFlash.&quote; & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {

//////////////////////////////FlASH CAN PLAY SO DO WHATEVER

		document.write('<OBJECT classid=&quote;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quote;');
	document.write('  codebase=&quote;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0&quote; ');
	document.write(' ID=&quote;YourFlashFile&quote; WIDTH=&quote;207&quote; HEIGHT=&quote;70&quote; ALIGN=&quote;left&quote;>');
	document.write(' <PARAM NAME=movie VALUE=&quote;images/banners/YourFlashFile.swf&quote;> <PARAM NAME=quality VALUE=high> <PARAM NAME=salign VALUE=L> <PARAM NAME=bgcolor VALUE=#FFFFFF>  '); 
	document.write(' <EMBED src=&quote;images/yourflashfile.swf&quote; quality=high salign=L bgcolor=#FFFFFF  ');
	document.write(' swLiveConnect=FALSE WIDTH=&quote;207&quote; HEIGHT=&quote;70&quote; NAME=&quote;YourImageName&quote; ALIGN=&quote;left&quote;');
	document.write(' TYPE=&quote;application/x-shockwave-flash&quote; PLUGINSPAGE=&quote;http://www.macromedia.com/go/getflashplayer&quote;>');
	document.write(' </EMBED>');
	document.write(' </OBJECT>');
} else{
	
/////NO FLASH SO DO SOMETHING ELSE
document.write('<IMG SRC=&quote;images/yourImage.gif&quote; WIDTH=&quote;207&quote; HEIGHT=&quote;70&quote; BORDER=0>');
}
//-->
</SCRIPT>

This code is generated by Flash when you publish your movie with html.

Hope that helps