skyzyx / plugin-detectors

Simple JavaScript objects to detect various plugins.

This URL has Read+Write access

skyzyx (author)
Sun Mar 22 13:33:32 -0700 2009
commit  704d3f7ac84bf61525b00e7f6f3b6e5fc3ecc6eb
tree    ef3c8de59189fa04074b1d117209077d4f38926a
parent  2837f1c669c3affbbde6c6ddd99e549002b48ad5
plugin-detectors / windowsmedia.js
100755 67 lines (58 sloc) 2.191 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************
WINDOWS MEDIA DETECT
All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
*******************************************************/
 
var windowsmedia=new Object();
 
// Set some base values
windowsmedia.installed=false;
windowsmedia.version='0.0'; // Internet Explorer-only
 
// Check for GeckoActiveXObject and co-inciding Plug-In
var gkoaxwma=false;
if (navigator.plugins && navigator.plugins.length) { for (x=0; x<navigator.plugins.length; x++) { if (navigator.plugins[x].name.indexOf('ActiveX') != -1 && window.GeckoActiveXObject) { gkoaxwma=true; break; } } }
 
// Create an ActiveX/GeckoActiveX constructor
function AXO(id)
{
var error; var control = null;
try {
if (window.ActiveXObject && navigator.userAgent.indexOf('Win') != -1) control = new ActiveXObject(id);
else if (gkoaxwma) control = new GeckoActiveXObject(id);
}
catch (error) {}
return control;
}
 
if (window.ActiveXObject || gkoaxwma)
{
try
{
oWMP=new AXO('WMPlayer.OCX.7');
if (oWMP)
{
windowsmedia.installed=true;
 
// A wierd bug in the Gecko ActiveX plug-in will return
// undefined at the first call, but the correct value on the second.
// This "fix" doesn't seem to hurt IE at all.
parseFloat(oWMP.versionInfo);
 
windowsmedia.version=parseFloat(oWMP.versionInfo);
if (windowsmedia.version.toString().length == 1) windowsmedia.version+='.0';
}
}
catch(e) {}
}
else if (navigator.plugins && navigator.plugins.length)
{
for (x=0; x<navigator.plugins.length; x++)
{
if (navigator.plugins[x].name.indexOf('Windows Media') != -1)
{
windowsmedia.installed=true;
break;
}
}
}
 
// Internet Explorer or GeckoActiveXObject-compatible browsers only.
windowsmedia.ver7=(windowsmedia.installed && parseInt(windowsmedia.version) >= 7) ? true:false;
windowsmedia.ver8=(windowsmedia.installed && parseInt(windowsmedia.version) >= 8) ? true:false;
windowsmedia.ver9=(windowsmedia.installed && parseInt(windowsmedia.version) >= 9) ? true:false;