PHP detecting if flash is installed

18,324

Solution 1

There's a better approach to this -

Use SWFObject to embed your .swf file. This is pretty much industry standard these days, nobody who knows what they're doing uses the pre-built Flash embed code.

The reason SWFObject will help you is that you basically tell it to go find a div on your site and replace it with a div containing embedded Flash. If the user doesn't have Flash installed, no problem - it just continues to display the original div.

The idea, then, is that you put your alt-content into the div that's going to be replaced by your .swf. This works very nicely, and should be perfect for what you need.

Solution 2

You cannot determine that on the server side (where PHP runs). You will have to detect it on the client side, using JavaScript, and either perform the wanted steps on the client side or communicating the result back to the server with a json/ajax/... request

You can download the Flash Player Detection Kit from Adobe

Solution 3

**Steps to get Javascript value in PHP code**

Using SWFObject JS file, you can get the playerversion (if flash player exists).

// Code to identify whether flash player installed or not 
var playerVersion = swfobject.getFlashPlayerVersion();

// set a cookie in Javascript and reload your page 
document.cookie="flashplayer_status" + "=" + playerVersion.release;

// Finally - We can get the Javascript cookie value 
// Whether Flash player is Installed in your
// System or not using PHP .. 

echo $_COOKIE['flashplayer_status'];

//Thats it!

Solution 4

EDIT: You shouldn't rely on the accept header as @bishop mentionned.

It only works reliably on IE browsers (and it shouldn't ;))

The only way is therefore some Javascript logic.

Legacy code for IE :

"application/x-shockwave-flash"

if(preg_match('/x-shockwave-flash/',$_SERVER['HTTP_ACCEPT'])) {
    /* flash logic comes here */
} else {
    /* no-flash logic comes here */
}
Share:
18,324
Tom
Author by

Tom

Updated on June 17, 2022

Comments

  • Tom
    Tom almost 2 years

    is it possible to detect if flash is installed using PHP. My aim is, that if it is installed it will play a flv file, and if not it will use another player eg; quicktime? If it is possible how do I go about doing it?

    Thanks Tom