Detecting a Player on a Consumer's Computer
To play media files that have been packaged with Microsoft® Windows Media™ Rights Manager, consumers must have a player that supports this format. These players include Microsoft® Windows Media™ Player version 6.2 or later, and any player that uses the latest Microsoft® Windows Media™ Audio Software Development Kit (SDK).
You can ensure that consumers who visit your Web site can play packaged media files by adding script to your site to detect whether a consumer's computer has a compatible player. Then, depending on the result, you can customize the download process. For example, a consumer visits your Web site, and then tries to download a media file. At that point, you verify whether the consumer has a compatible player. If so, downloading continues. Otherwise, the consumer is taken to a page where a compatible player can be downloaded.
By default, a license is issued after a consumer has downloaded a media file and tried to play it, but you can change this process if you create your own license-acquisition script. For example, you can issue a license for a media file while it is being downloaded or before the media file is downloaded. When you issue a license in this way, you embed the player in the Web browser, so the consumer must have a player, such as Windows Media Player, that supports being embedded in this way. So before you issue the license, you can verify that the consumer's computer has a player that can be embedded.
This article contains information about the process of detecting players on a consumer's computer, how the script samples work, two sample scripts, and where to go for additional information, as follows:
Detecting players
Using the first sample script
Using the second sample script
Additional information
On This Page
Detecting players
Using the first sample script
Using the second sample script
Additional information
Detecting players
When a player that can play packaged media files is installed on a computer, that computer can then store licenses. Therefore, you can detect whether a consumer's computer has a compatible player by determining if the computer can store licenses.
On computers running Microsoft® Internet Explorer, check the response to the DRMStore ActiveX® object to see if a Windows Media Rights Manager-compatible player is present. In addition, check the response to WMPlay to see if Windows Media Player version 6.2 or later is present. On computers running Netscape Navigator, you can find out if specific plug-ins are installed.
Because consumers can use any Web browser, consider using Microsoft® JScript® to support the latest versions of both Internet Explorer and Netscape unless you want to write code to detect the version and type of Web browser that the consumer is using.. However, you can easily use Microsoft® Visual Basic® Scripting Edition (VBScript) with JScript without causing problems for Netscape users.
Using the first sample script
The first sample script checks the consumer's computer for the presence of a player that can play packaged media files. It also specifically checks for Windows Media Player version 6.2 or later (you can write a script that looks for a different player if you want).
You can add similar script to your download process. For example, if you are using the Web site that was installed with Windows Media Rights Manager, you add script to the Download.asp and Download4.asp pages.
About the logic
The script contains code that applies to both Internet Explorer and Netscape. The Web browser ignores the code that does not apply to it. For example, if a consumer is using Internet Explorer, the code for Netscape is ignored. When this script is run, it displays two messages indicating whether a Windows Media Rights Manager-compatible player has been detected, and whether Windows Media Player version 6.2 or later has been detected.
Code for Internet Explorer
To check for the presence of a player that supports packaged files, the script tries to create a DRMStore object, and then calls the StoreLicense method, using an empty string as a parameter. (Normally with this method, you would use a valid license string as the parameter, but in this case, you are just looking for any response from the object.) If the object is installed on the computer, the object responds with no error, verifying that a compatible player exists on the computer. (This method does not store any information on the consumer's computer.)
To check for the presence of a specific version of Windows Media Player, the script tries to create a WMPlay object, and then calls the FileName method, using an empty string as a parameter. If the object is installed on the computer, the object responds, verifying that Windows Media Player version 6.2 or later is installed.
Code for Netscape
The Netscape object model can indicate which plug-ins are installed, so the script uses a Netscape object to check for two specific Netscape plug-ins. The presence of one plug-in indicates that a compatible player is present, and the presence of the other plug-in indicates that Windows Media Player version 6.2 or later is present. You do not have to use embed tags.
The sample script
<html> <head> <object WIDTH="1" HEIGHT="1" classid="CLSID:760C4B83-E211-11D2-BF3E-00805FBE84A6" id="DrmStore"> </object> <object ID="WMPlay" WIDTH="1" HEIGHT="1" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="#Version=6,2,5,410"> </object> <title></title> </head> <body> <script LANGUAGE="VBScript"> function drmexists() on error resume next DrmStore.StoreLicense("") if (err.number = 0) then drmexists = true else drmexists = false end if end function </script> <script LANGUAGE="JavaScript"> var fHasDRM1 = false; var fHasDRM2 = false; var fHasDRM = false; var fHasMP1 = false; var fHasMP2 = false; var fHasMP = false; function ignoreerror() { return true; } window.onerror=ignoreerror; fHasDRM1 = navigator.mimeTypes && navigator.mimeTypes["application/x-drm"] && navigator.mimeTypes["application/x-drm"].enabledPlugin; fHasMP1 = navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin; if (typeof(DrmStore) != "undefined") { fHasDRM2 = drmexists(); } if (typeof(WMPlay) != "undefined") { fHasMP2 = (WMPlay.FileName == ""); } fHasDRM = fHasDRM1 || fHasDRM2; fHasMP = fHasMP1 || fHasMP2; if (fHasDRM) { alert("You have a Windows Media Rights Manager-compatible player."); } else { alert("You do not have a Windows Media Rights Manager-compatible player."); } if (fHasMP) { alert("You have Microsoft Windows Media Player version 6.2 or later."); } else { alert("You do not have Microsoft Windows Media Player version 6.2 or later."); } </script> </body> </html>
Using the second sample script
The second sample script is simpler than the first sample, and only shows how to detect the presence of Windows Media Player and display its version number.
<HTML> <head> <title>Detecting Windows Media Player</title> <SCRIPT LANGUAGE="JavaScript"> <!-- var fHasWMP52 = navigator.mimeTypes && navigator.mimeTypes["application/x-mplayer2"] && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin; var fHasWMP64 = navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin && navigator.mimeTypes["video/x-ms- wmv"] && navigator.mimeTypes["video/x-ms-wmv"].enabledPlugin; //--> </SCRIPT> </head> <body> <OBJECT ID="NSPlay" WIDTH=1 HEIGHT=1 classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="#Version=6,4,5,715"> </object> Windows Media Player is <SCRIPT LANGUAGE="VBScript"> <!-- On error resume next fHasWMP52 = (IsObject(CreateObject("MediaPlayer.MediaPlayer.1") ) ) fHasWMP64 = (NSPlay.FileName="") //--> </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> <!-- if( fHasWMP64 ) { document.write("version 6.4 or higher."); } else if( fHasWMP52 ) { document.write("version 5.2 or higher."); } else { document.write( "not installed." ); } //--> </SCRIPT> </BODY> </HTML>
Additional information
To learn more about Windows Media Rights Manager, see Windows Media Rights Manager Help. Windows Media Rights Manager is available for download from the Windows Media Technologies page at the Microsoft Web site (https://www.microsoft.com/windows/windowsmedia/default.aspx).
Packaging Media Files in Batches https://msdn.microsoft.com/workshop/imedia/windowsmedia/Batchpac.asp
Integrating Windows Media Rights Manager with Other Applications https://msdn.microsoft.com/workshop/imedia/windowsmedia/Integrat.asp
Setting Up Media Files for Subscriptions and Streaming https://msdn.microsoft.com/workshop/imedia/windowsmedia/Substream.asp
Distributing a License with a Media File https://msdn.microsoft.com/workshop/imedia/windowsmedia/liccont.asp
Comparing Server Configurations for Issuing Licenses https://msdn.microsoft.com/workshop/imedia/windowsmedia/Scalability.asp