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

Using DVD Event Codes

An event code is code that executes when an event occurs. An event is an action, recognized by the DVD object, for which you can write code to respond. Events can be generated by a user action, such as clicking the mouse or pressing a key on the keyboard. Events are also generated by the system itself, for example, in the case of timers.

DVD-specific events are returned to the Microsoft® Windows Media™ Player control through the DVDNotify event in the following form.

 MediaPlayer_DVDNotify(Event, Param1, Param2)

The following subroutine shows a way to capture the DVD event codes in Microsoft® Visual Basic® Scripting Edition. Note that the DVD event codes should be referred to by a constant integer value, ranging from 257 to 272, 274, or 275. To illustrate how the DVD event codes work, use the DIV tag to create two sections that will display the current event code and the values of its parameter list.

<TABLE>
<TR>
<TD><DIV ID=codeConstant> </DIV></TD>
<TD><DIV ID=paramList> </DIV></TD>
</TR>
<TABLE>

After enumerating the event codes, the following code shows you how to display the events and the values of their parameters as they are returned to the Windows Media Player control.

strEventCode = szDVDEventCode(eventOffset)
codeConstant.innertext = "DVDNotify EventCode = " + CStr(EventCode) + _
" = " + strEventCode
paramList.innertext  = "Param1 = " + CStr(Param1) + "  Param2 = " + _
CStr(Param2)

For the complete example, showing the necessary variables, the enumeration of the event codes, and the displaying of the incoming event codes and parameters, click the following link.

Sample Code

A more typical use of event codes would be to capture the current time of the DVD, allowing the current time to be displayed on the page. For example, the following code uses a DIV tag to set aside a separate, distinct section to hold the current time value.

<DIV ID=timeshow> </DIV>

Then, add the DVDNotify event to your subroutine list, as shown in the following:

Sub MediaPlayer1_DVDNotify(EventCode, Param1, Param2 )
  If EventCode = 267 Then    'EC_DVD_CURRENT_TIME = 267
    timeshow.innertext = Left(MediaPlayer1.DVD.CurrentTime, 8)
  End If
End Sub

Now, when an EC_DVD_CURRENT_TIME event occurs, the value for the current time will be placed in the timeshow DIV. Use the VBScript Left function to extract the eight left-most characters from the string containing the current time value.

The Windows Media Player control supports the following DVD event codes. For more information, see DVD Event Codes in the Scripting Reference section.


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