Mac OS X check if flash is installed
My Mac OS X application opens a webpage via a WebView that requires flash. If the user does not have flash installed I would like to give them a popup telling them to please install flash.
Is there a way to check the webview if the flash plugin is installed? In WebPreferences you can enable/disable PlugIns but I can't find a way to query the 开发者_C百科currently install/enabled ones.
Thanks for any help.
You may be able to write some JavaScript that does the checks and execute it through the WebView's window object. To do this you'll need to read up on JavaScript's navigator
object, specifically navigator.plugins
.
You can check the installed Flash version via a shell command:
/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/Info.plist
Apple has provided JavaScript code to detect plugins on a variety of browsers. If you include this file, the following can be used redirect either to the Flash site or to your popup:
detectFlash("http://www.site.com/flashcontent","http://www.site.com/noflash")
Per @Brian Kyle's excellent suggestion, it is possible to check for Flash in navigator.plugins:
var pluginCount = navigator.plugins.length;
for(var i = 0; i < pluginCount; i++){
if(navigator.plugins[i].name=="Shockwave Flash") {
document.write("Flash version " + navigator.plugins[i].version);
break;
};
};
精彩评论