We are using a proprietary document viewer which doesn\'t play terribly nice with the Pepper version of Flash found in some flavors of Chrome, so I\'d like to be able to detect
I made a cleaner version of this method using regexp. Includes tests.
http://jsfiddle.net/YNCVh/
>>> Currently Running Pepper? true
>>> Test Case Plugin Matched? pepflashplayer.dll : true
>>> Test Case Plugin Matched? PepperFlashPlayer.plugin : true
>>> Test Case Plugin Matched? libpepflashplayer.so : true
/**
* Regular expression to test for pepper PPAPI plugins
*/
var PPAPI_REGEX = /^(lib)?pep(per)?flashplayer/i;
/**
* Returns true if the current agent is running PPAPI version of flash
*/
function runningPepperFlash() {
if (navigator.plugins) {
for (var i = 0, count = navigator.plugins.length; i < count; i++) {
var plugin = navigator.plugins[i].filename;
var has_pepper = PPAPI_REGEX.test(plugin);
if (has_pepper) {
return true;
}
}
return false;
}
}
// ----------------------------------------------------------
// test cases:
/**
* Test case against the three (3) known plugin file types (win,mac,linux)
*/
function executeTestCases() {
var plugins = ['pepflashplayer.dll', 'PepperFlashPlayer.plugin', 'libpepflashplayer.so'];
for (var i = 0; i < plugins.length; i++) {
var has_pepper = PPAPI_REGEX.test(plugins[i]);
console.log('Test Case Plugin Matched? ', plugins[i], ': ', has_pepper);
}
}
console.log('Currently Running Pepper?', runningPepperFlash());
executeTestCases();