Windows Media Player Control SDK Banner Art
*Index  *Topic Contents
*Previous Topic: DVD Overview
*Next Topic: Using DVD Properties

Viewing DVD in a Web Page

The Microsoft® Windows Media™ Player control uses automation to expose the DVD-Video–specific interfaces, methods, events, and properties of the Microsoft® DirectShow® Application Programming Interface (API). As a Microsoft® ActiveX® control, the Windows Media Player control can be used as a component in a Web page. Enhanced with digital video disc (DVD) playback capability, the Windows Media Player control adds exciting dynamic content to previously static Web pages.

You can view a Microsoft® Visual Basic® Scripting Edition (VBScript) sample page demonstrating DVD playback in a Web page that builds upon the concepts introduced in this article. To view this sample, your system must be capable of DVD-Video playback and have the Microsoft DirectShow drivers installed.

This article contains the following sections.

Customizing the Control for DVD Playback

By using a scripting language, such as VBScript or Microsoft® JScript®, it is easy to place the Windows Media Player control in an HTML file. This section contains the following topics, which explain how to embed the Windows Media Player control into an HTML page, how to enable the Windows Media Player control to play back DVD, and how to use VBScript routines to manipulate it.

Inserting the Windows Media Player Control

The OBJECT tag is used to embed ActiveX objects, such as the Windows Media Player control, into an HTML page. The following code is an example of using the OBJECT tag to insert the Windows Media Player control.

<OBJECT CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" WIDTH="652"
    HEIGHT="382" ID="MediaPlayer1">
</OBJECT>

The following OBJECT tag attributes are required.

Setting Control Properties with the PARAM Tag

One option for setting the properties of a control in a Web page is adding PARAM tags between the OBJECT tags. This is an ideal way to set design time properties. The following code is an example of the OBJECT tag with PARAM tags added.

<OBJECT CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" WIDTH="652"
    HEIGHT="382" ID="MediaPlayer1">
<PARAM NAME="AutoStart" VALUE="0">
<PARAM NAME="Filename" VALUE="DVD:">
<PARAM NAME="ShowControls" VALUE="0">
</OBJECT>

The PARAM tags used in the preceding example have two attributes; the first is the name of the property being set, and the second specifies the value of the property. In the preceding example, the first PARAM tag sets the AutoStart property to false. The remaining PARAM tags change the default values of the FileName property to DVD: and the ShowControls property to false. Note that none of the DVD-specific properties can be set by using the PARAM tag.

It is critical to note that DVD playback is triggered by setting the FileName property to DVD:, which instructs the Windows Media Player control to search for the DVD drive on the local system. If the AutoStart property is set to true (the default value), the Windows Media Player control will then begin DVD playback; otherwise, an event must be associated with DVD playback, such as the selection of a button.

Adding a Simple User Interface

You can create a simple user interface by adding the following two groups of button controls to the body of your HTML page: one to control menu selection and one to control the DVD playback state.

The following code creates the button controls to handle the selection of menu items from the DVD menu screen.

<INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdTopSelect" VALUE="Top">
<INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdLeftSelect" VALUE="Left">
<INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdRightSelect" VALUE="Right">
<INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdBottomSelect" VALUE="Bottom">
<INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdButtonActivate" VALUE="Select">

The following code creates the button controls that will handle basic playback (play, pause, and stop), as well as chapter searching and scanning.

<INPUT TYPE="BUTTON" STYLE="WIDTH:60" NAME="cmdPlay" VALUE="Play">
<INPUT TYPE="BUTTON" STYLE="WIDTH:60" NAME="cmdPause" VALUE="Pause">
<INPUT TYPE="BUTTON" STYLE="WIDTH:60" NAME="cmdStop" VALUE="Stop">
<INPUT TYPE="BUTTON" STYLE="WIDTH:60" NAME="cmdResume" VALUE="Resume">
<INPUT TYPE="BUTTON" STYLE="WIDTH:60" NAME="cmdShowMenu" VALUE="Menu">
<INPUT TYPE="BUTTON" NAME="cmdPrevChapter" VALUE="|<<">
<INPUT TYPE="BUTTON" NAME="cmdRewind" VALUE="<<">
<INPUT TYPE="BUTTON" NAME="cmdFastForward" VALUE=">>">    
<INPUT TYPE="BUTTON" NAME="cmdNextChapter" VALUE=">>|">

Adding the Scripting Code

Scripting code adds interactivity to your page, enabling you to programmatically respond to events, to call methods, and to change run-time properties.

First, you must notify the browser which scripting language you are authoring with by using the HTML SCRIPT tag. Include your script commands within HTML comment tags so browsers that do not support scripting do not render your code as text. Put the SCRIPT tag anywhere within the BODY of your HTML file and embed the comment-surrounded code within the opening and closing SCRIPT tags.

The following code demonstrates how each subroutine is attached to the OnClick event of a specific button that was previously defined. When an event is triggered by a button being clicked, the code makes a call (or series of calls) to the Windows Media Player control, specifying the action to be taken.

Sample Code

Creating a DVD-Enabled Web Page

By combining the elements previously discussed in this article, you can see how the pieces fit together in the following sample code.

Try the following sample code to showcase the Windows Media Player control's capabilities on a system with DVD-Video capabilities. Copy and paste the code into a text file and save it with the .htm extension.

Sample Code


Top of Page Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.