Windows Media Player SDK banner art
PreviousNext

Customizing the Control for DVD Playback

This topic applies to Windows Media Player version 6.4 only.

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

This topic applies to Windows Media Player version 6.4 only.

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

This topic applies to Windows Media Player version 6.4 only.

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

This topic applies to Windows Media Player version 6.4 only.

You can create a simple user interface by adding 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

This topic applies to Windows Media Player version 6.4 only.

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.

<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>
PreviousNext


© 2000-2001 Microsoft Corporation. All rights reserved.