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-Videospecific 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
- Setting Control Properties with the PARAM Tag
- Adding a Simple User Interface
- Adding the Scripting Code
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.
- ID Name used to reference this instance of the control.
- CLSID Class Identifier (CLSID) of the Windows Media Player control. A CLSID is a Component Object Model (COM) object identifier.
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
<SCRIPT LANGUAGE="VBScript"> <!-- Dim isScanning isScanning = False Sub cmdPlay_OnClick() If isScanning Then MediaPlayer1.DVD.ForwardScan(1) Else MediaPlayer1.Play() End If isScanning = False End Sub Sub cmdPause_OnClick() MediaPlayer1.Pause() End Sub Sub cmdStop_OnClick() MediaPlayer1.Stop() End Sub Sub cmdResume_OnClick() MediaPlayer1.DVD.ResumeFromMenu() End Sub Sub cmdShowMenu_OnClick() MediaPlayer1.DVD.MenuCall(3) End Sub Sub cmdPrevChapter_OnClick() MediaPlayer1.DVD.PrevPGSearch() End Sub Sub cmdNextChapter_OnClick() MediaPlayer1.DVD.NextPGSearch() End Sub Sub cmdFastForward_OnClick() isScanning = True MediaPlayer1.DVD.ForwardScan(5) End Sub Sub cmdRewind_OnClick() isScanning = True MediaPlayer1.DVD.BackwardScan(5) End Sub Sub cmdTopSelect_OnClick() MediaPlayer1.DVD.UpperButtonSelect() End Sub Sub cmdLeftSelect_OnClick() MediaPlayer1.DVD.LeftButtonSelect() End Sub Sub cmdRightSelect_OnClick() MediaPlayer1.DVD.RightButtonSelect() End Sub Sub cmdBottomSelect_OnClick() MediaPlayer1.DVD.LowerButtonSelect() End Sub Sub cmdButtonActivate_OnClick() Dim buttonNumber buttonNumber = MediaPlayer1.DVD.CurrentButton MediaPlayer1.DVD.ButtonSelectAndActivate(buttonNumber) End Sub --> </SCRIPT>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
<HTML> <HEAD> <TITLE>DVD_Demo</TITLE> </HEAD> <BODY BGCOLOR="#000000" TEXT="#00FFFF"> <CENTER> <TABLE> <TR> <TD VALIGN="TOP" WIDTH="10%"> </TD> <TD> <P ALIGN="center"> <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> </P> </TD> <TD VALIGN="TOP" WIDTH="10%"> Menu Select <BR> <INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdTopSelect" VALUE="Top"> <BR> <INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdLeftSelect" VALUE="Left"> <BR> <INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdRightSelect" VALUE="Right"> <BR> <INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdBottomSelect" VALUE="Bottom"> <P> <INPUT TYPE="BUTTON" STYLE="WIDTH:70" NAME="cmdButtonActivate" VALUE="Select"> <P> </TD> </TR> </TABLE> </CENTER> <CENTER> <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"> <P> <INPUT TYPE="BUTTON" NAME="cmdPrevChapter" VALUE="| < <"> <INPUT TYPE="BUTTON" NAME="cmdRewind" VALUE=" < <"> <INPUT TYPE="BUTTON" NAME="cmdFastForward" VALUE=" > >"> <INPUT TYPE="BUTTON" NAME="cmdNextChapter" VALUE=" > >|"> </CENTER> <SCRIPT LANGUAGE="VBScript"> <!-- Dim isScanning isScanning = False Sub cmdPlay_OnClick() If isScanning Then MediaPlayer1.DVD.ForwardScan(1) Else MediaPlayer1.Play() End If isScanning = False End Sub Sub cmdPause_OnClick() MediaPlayer1.Pause() End Sub Sub cmdStop_OnClick() MediaPlayer1.Stop() End Sub Sub cmdResume_OnClick() MediaPlayer1.DVD.ResumeFromMenu() End Sub Sub cmdShowMenu_OnClick() MediaPlayer1.DVD.MenuCall(3) End Sub Sub cmdPrevChapter_OnClick() MediaPlayer1.DVD.PrevPGSearch() End Sub Sub cmdNextChapter_OnClick() MediaPlayer1.DVD.NextPGSearch() End Sub Sub cmdFastForward_OnClick() isScanning = True MediaPlayer1.DVD.ForwardScan(5) End Sub Sub cmdRewind_OnClick() isScanning = True MediaPlayer1.DVD.BackwardScan(5) End Sub Sub cmdTopSelect_OnClick() MediaPlayer1.DVD.UpperButtonSelect() End Sub Sub cmdLeftSelect_OnClick() MediaPlayer1.DVD.LeftButtonSelect() End Sub Sub cmdRightSelect_OnClick() MediaPlayer1.DVD.RightButtonSelect() End Sub Sub cmdBottomSelect_OnClick() MediaPlayer1.DVD.LowerButtonSelect() End Sub Sub cmdButtonActivate_OnClick() Dim buttonNumber buttonNumber = MediaPlayer1.DVD.CurrentButton MediaPlayer1.DVD.ButtonSelectAndActivate(buttonNumber) End Sub --> </SCRIPT> </BODY> </HTML>
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.