May 10, 2001 - Checking the Plug-ins for Mac and Win Navigator | WebReference

May 10, 2001 - Checking the Plug-ins for Mac and Win Navigator

Yehuda Shiran May 10, 2001
Checking the Plug-in Installation
Tips: May 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

In some of your applications you may need to use Flash Audio and JavaScript directly, without any prepackaged APIs such as the FlashSound JavaScript API. You will enjoy more features, methods, and properties, but you'll have to take care of all the tiny details that are taken for granted when using the FlashSound API.

One of these tiny details is checking that the Flash plug-in is installed in Mac or Windows Navigator. The following function, Flash_checkForPlugIn(), does exactly that. It checks that the mimeTypes object exists, that one of the mime types is flash, and that its relevant plug-in is enabled. The function also extracts the plug-in version, and checks that it is higher than the default minimum player version. The default minimum player version is set as a global variable before calling Flash_checkForPlugIn(). Here is the function in full, remember that it must be preceded by the global variable assignment of minPlayer:

function Flash_checkForPlugIn() {
  var plugin = (navigator.mimeTypes &&
  navigator.mimeTypes["application/x-shockwave-flash"]) ?
  navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if (plugin) {
    var pluginversion =    
  parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) 
  if(pluginversion >= minPlayer) {return true;}
  }
  return false;
}