//Detect ActiveX Architecture on Both IE and on Gecko //Defer to plugin architecture for other browsers function detectWMP() { var wmpInfo = { installed: false, scriptable: false, type: null, versionInfo: null }; var wmp64 = "MediaPlayer.MediaPlayer.1"; var wmp7 = "WMPlayer.OCX.7"; if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1) || window.GeckoActiveXObject) { wmpInfo.type = "ActiveX"; var player = createActiveXObject(wmp7); if(player) { wmpInfo.installed = true; wmpInfo.scriptable = true; wmpInfo.versionInfo = player.versionInfo; return wmpInfo; } else { player = createActiveXObject(wmp64); if(player) { wmpInfo.installed = true; wmpInfo.scriptable = true; wmpInfo.versionInfo = "6.4"; return wmpInfo; } else { wmpInfo.versionInfo = "none"; return wmpInfo; } } } else if(navigator.mimeTypes) { wmpInfo.type = "NetscapePlugin"; var player = navigator.mimeTypes['application/x-mplayer2'].enabledPlugin; if(player) { wmpInfo.installed = true; //wmpInfo.scriptable = false; wmpInfo.versionInfo = "PluginVersion"; return wmpInfo; } return wmpInfo; } } function createActiveXObject(id) { var error; var control = null; try { if (window.ActiveXObject) { control = new ActiveXObject(id); } else if (window.GeckoActiveXObject) { control = new GeckoActiveXObject(id); } } catch (error) { ; } return control; } function printResults() { var detectionResults = detectWMP(); document.write("Browser architecture supports: " + detectionResults.type + "\n"); document.write("Windows Media Player Installed: " + detectionResults.installed + "\n"); if(detectionResults.installed) { document.write("Windows Media Scriptable: " + detectionResults.scriptable + "\n"); document.write("Windows Media Version: " + detectionResults.versionInfo + "\n"); } }