Contents Index Topic Contents | |
Previous Topic: Plug-in Samples Next Topic: Windows Media Player Custom Player Kit |
Detecting a Player on a Consumer’s Computer
To play media files that have been packaged with Microsoft® Windows Media™ Rights Manager, a consumer 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). For information about Windows Media Rights Manager, see Windows Media Rights Manager Help.
To ensure that consumers who visit your Web site can play packaged media files, you can add 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 the following sections:
Detecting Players
When a player that can play packaged media files is installed on a computer, that computer is enabled to store licenses. Therefore, you can detect whether a consumer’s computer has a compatible player by determining whether 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 whether 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.
About the Logic of the Player-detection Script
The example script checks the consumer’s computer for the presence of a player that can play packaged media files. It 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).
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 need to use embed tags.
Player-detection Script
This example script shows how to detect the presence of a Windows Media Rights Manager-compatible player and specifically Windows Media Player version 6.2 or later. 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.
<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>
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.