I think this should be done as follows:
var isPPAPI = false; var type = 'application/x-shockwave-flash'; var mimeTypes = navigator.mimeTypes; if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.filename == 'pepflashplayer.dll') isPPAPI = true;
Demo on jsFiddle .
UPD # 1: Not sure if needed, but I wrote a short explanation:
If our browser has an enumeration of MIME types, we can get a plugin associated with the specified type. Therefore, we get the plugin associated with 'application/x-shockwave-flash' and check if its file name is 'pepflashplayer.dll' . I think this name is permanent and will not be changed in the future.
UPD No. 2:
To enable / disable PPAPI in Google Chrome, go to this page: chrome://plugins/
(Sorry, this URL needs to be inserted directly into the address bar.)
UPD No. 3:
I did some research and found an interesting article that helped me implement a cross-platform solution. I think this code should work on all OSs:
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;
Check out the updated fiddle .
UPD No. 4:
Changed the code a bit to fit today's realities. Now the condition is as follows:
if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && (mimeTypes[type].enabledPlugin.filename.match(/pepflashplayer|Pepper/gi))) isPPAPI = true;
Check out jsFiddle .
source share