Last active
December 17, 2015 20:59
-
-
Save JamesMGreene/5671629 to your computer and use it in GitHub Desktop.
A little code snippet to check if the current browser is enabled to use the Chromium built-in PPAPI (a.k.a. "Pepper") Flash Player, i.e. instead of the Adobe Flash Player (or some other player, e.g. Gnash, Klash, etc.).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: Some code taken from this StackOverflow question: | |
// http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript | |
var isUsingPepperFlash = (function() { | |
var getFlashPlayerFileName = function(mimeTypes, type) { | |
return ( | |
mimeTypes && | |
mimeTypes[type] && | |
mimeTypes[type].enabledPlugin && | |
mimeTypes[type].enabledPlugin.filename | |
) || ''; | |
}; | |
return function() { | |
var isPPAPI = false; | |
var mimeTypes = window.navigator.mimeTypes; | |
var flashMimeType = "application/x-shockwave-flash"; | |
var flashPlayerFileName = getFlashPlayerFileName(mimeTypes, flashMimeType).toLowerCase(); | |
if (flashPlayerFileName && | |
flashPlayerFileName === "pepflashplayer.dll" || | |
flashPlayerFileName === "libpepflashplayer.so" || | |
flashPlayerFileName === "pepperflashplayer.plugin") | |
{ | |
isPPAPI = true; | |
} | |
return isPPAPI; | |
}; | |
})(); | |
alert("Using Pepper Flash? " + isUsingPepperFlash()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I originally implemented this in a fiddle: