How to Check Flash Player is Installed and Enabled in Chrome in JavaScript

Macromedia-Flash-iconIn Google Chrome there is an option to turn of running any browser plugin (like Flash, Java etc) from running automatically. So sometimes we need to check whether Flash player is installed and enabled or not in Chrome. Normally we can check it with below code:

((typeof navigator.plugins != 'undefined' && typeof navigator.plugins['Shockwave Flash'] == 'object') ||
 (window.ActiveXObject && (new ActiveXObject('ShockwaveFlash.ShockwaveFlash')) != false));

If we disable plugin individually, above query works and return false, but If we block all plugin it will return true… we can use swfobject to handle flash detection, but how can we check it in Javascript?  Thanks god I got the solution from jsfiddle, source code as below:

var isPPAPI = false;
var type = 'application/x-shockwave-flash';
var mimeTypes = navigator.mimeTypes;

var endsWith = function(str, suffix) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin &&
   (mimeTypes[type].enabledPlugin.filename == "pepflashplayer.dll" ||
    mimeTypes[type].enabledPlugin.filename == "libpepflashplayer.so" ||
    endsWith(mimeTypes[type].enabledPlugin.filename, "Chrome.plugin"))) isPPAPI = true;

alert("PPAPI enabled: " + isPPAPI);

Cheers!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed Follow us Follow us
You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply