Please read the disclaimer before using any code shown.
Windows Media Player [DRM]
comes in quite a few flavours, however the most useful, from a protection
point of view is DRM2.2+. This comes with Windows Media Player 7 and the individualisation update
(the [DRM SDK]
for WM9 adds signed headers, and live DRM).
However, because 2.2 requires an update over and above the WM7 player it
can be useful to check the client machine setup before allowing them to signup for licenses, or
before you issue a license. Unfortunately it's not as simple as querying the WMP version number.
The testing process can be broken down into 3 stages. If a stage is not passed
there is no need to continue, DRM 2.2 will not work. The checking process itself can only run within IE.
Check the current OS and browser DRM 2.2 is only available on Windows 98 onwards, there is no Mac version
Check the version of media player This is checked by looking at the mime types the
browser is requesting, then attempting to create a WM7 object.
Check the individualisation properties of the player created in the previous step
Prerequisites
Scripting must be enabled on the browser. Don't forget to use the <noscript>
tag to display an error message for users with scripting disabled.
Step 1 : Check the OS and browser version
This is standard stuff and everyone has their own favourite way of doing this. If you look at the
source for this page, you will see I use browserSniff.js, which is available from
[mozilla.org]. You could
also look at [BrowserSpy] which also has a Windows Media version
check, but no DRM version checking.
Check that the client OS is Windows 98 or greater, remember DRM2+ is not supported
on any other OS.
Check that the client is using IE 5+. If they are not, the test cannot
continue. Note they may still be able to play DRM content, but there is no way of checking.
Step 2 : Check the version of media player
This is where the fun begins.
To check for a basic version of Media Player, either 5 or 6, we need to check
what MIME types the browser is capable of handling. To do this we use the
[navigator]
javascript object and check for "application/x-mplayer2", which indicates Media Player
5.2, then for "video/x-ms-wm" which indicates Media Player 6.4.
Note that other players, such
as WinAmp or Real One can also handle these MIME types, but the check for the WM7 object will
not pass with 3rd party players.
To check the MIME types your javascript should look like the following:
You now have 2 variables, fHasWMP52 and fHasWMP64 which you can check on.
Your overall page flow should
combine the checks against these variables with the checks in step 1 so if the client machine has
the correct OS, the correct browser and if fHasWMP64 is true you can proceed to checking for WMP7.
If all the tests so far have been sucessful you now need to check for WMP7.
This is checked by using VBScript on the client (hence the need for IE). We try to create a
WMP7 object and if an error occurs we can assume WMP7 is not installed.
<script language="VBScript" type="text/vbscript">
<!--
dim fHasMP70
On Error Resume Next
fHasMP70 = IsObject(CreateObject("WMPlayer.OCX"))
On Error Goto 0
-->
</script>
By using On Error Resume Next we supress any error messages. The variable fHasWMP70
now contains true if we can create a WMP7 object, or false if an error occured.
If any of these checks fail you can use
[document.write]
to inform the user and provide a download link to the latest version of
[Windows Media Player].
Checking for WM9
Should you want to check that the user is running WMP9 you need to tweak
the WM7 check, then add some additional javascript.
<script language="VBScript" type="text/vbscript">
<!--
dim objMP70, fHasMP70, fHasMP90, sMPVersion
On Error Resume Next
fHasMP70 = IsObject(CreateObject("WMPlayer.OCX"))
if fHasMP70 then
set objMP70 = CreateObject("WMPlayer.OCX")
sMPVersion = left(objMP70.versionInfo, 1)
if sMPVersion = "9" then
fHasMP90 = true
end if
end if
On Error Goto 0
-->
</script>
Step 3: Check the individualisation
Now that we know the user has WMP7 or WMP9 installed, we can check the individualisation version.
The original version was 2.0, but this was cracked (nothing is ever 100% secure, if you think
it is I have a bridge I'd like to sell you).
Microsoft designed
Windows Media DRM so updates could be easily delivered, and the individualisation update was the
patch to prevent the WM crack. This patch is not installed by default in either WM7 or WM9.
You should be packaging DRM content
against v2.2, Microsoft do not issue the registry keys for delivering 2.0 licenses
any more. So you need to check a client install for individualisation/security version 2.2.
To check the client security version we need to create a WMP security and licensing object. Obviously
you only create this once you are sure the client is running WM7+.
The code shown creates the necessary object, then calls the checkIndividualisation(); function.
checkIndividualisation(); uses IE5's XML and
[string]
[regex] functions
to parse the security information the security and licensing object returns.
function checkIndividualisation()
{
var sXMLCommand, objClientInformation, objXMLDOM, xmlNode;
var sFoundSec;
var nRequiredSec = '2200', nFoundSec = 0.0;
sFoundSec = new String('0.0')
xmlNode = objXMLDOM.selectSingleNode("MEDIATEST/CLIENTINFO/SECURITYVERSION");
if (xmlNode)
{
var sRegEx
sRegEx = /\./g;
sFoundSec = String(xmlNode.text);
sFoundSec = sFoundSec.replace(sRegEx, '');
}
if (Number(sFoundSec) < nRequiredSec)
// individualisation doesn't meet the minimum required level
else
// Finally, we're done, and everything looks ok.
}
The function shown checks against nRequiredSec, set as '2200', which
represents DRM version 2.2.0.0. Once the check is complete you can use document.write() to
display a success or failure method.
Of course there are bound to be situations where the tests shown should
work, but don't, or a client suceeds when it shouldn't have. If you do find problems please
[let me know].
So, does it all work?
Checking your machine
Disclaimer
All code provided above is provided on an "AS IS" basis, without warranty.
The author does not make any representation, or warranty, either express or implied,
with respect to the programs, their quality, accuracy, or fitness for a specific purpose.
Therefore, the author shall not have any liability to you or any other person or entity with
respect to any liability, loss, or damage caused or alleged to have been caused directly or
indirectly by the code provided. This includes, but is not limited to,
interruption of service, loss of data, loss of profits, or consequential damages from the
use of these programs.