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
Sub MediaPlayer1_DVDNotify(EventCode, Param1, Param2) Dim strEventCode Dim strParam1 Dim szDVDEventCode(20) Dim eventOffset eventOffset = EventCode - 257 szDVDEventCode(0) = " (EC_DVD_DOMAIN_CHANGE)" szDVDEventCode(1) = " (EC_DVD_TITLE_CHANGE)" szDVDEventCode(2) = " (EC_DVD_CHAPTER_START)" szDVDEventCode(3) = " (EC_DVD_AUDIO_STREAM_CHANGE)" szDVDEventCode(4) = " (EC_DVD_SUBPICTURE_STREAM_CHANGE)" szDVDEventCode(5) = " (EC_DVD_ANGLE_CHANGE)" szDVDEventCode(6) = " (EC_DVD_BUTTON_CHANGE)" szDVDEventCode(7) = " (EC_DVD_VALID_UOPS_CHANGE)" szDVDEventCode(8) = " (EC_DVD_STILL_ON)" szDVDEventCode(9) = " (EC_DVD_STILL_OFF)" szDVDEventCode(10) = " (EC_DVD_CURRENT_TIME)" szDVDEventCode(11) = " (EC_DVD_ERROR)" szDVDEventCode(12) = " (EC_DVD_WARNING)" szDVDEventCode(13) = " (EC_DVD_CHAPTER_AUTOSTOP)" szDVDEventCode(14) = " (EC_DVD_NO_FP_PGC)" szDVDEventCode(15) = " (EC_DVD_PLAYBACK_RATE_CHANGE)" szDVDEventCode(17) = " (EC_DVD_PLAYBACK_STOPPED)" szDVDEventCode(18) = " (EC_DVD_ANGLES_AVAILABLE)" strEventCode = szDVDEventCode(eventOffset) codeConstant.innertext = "DVDNotify EventCode = " + _ CStr(EventCode) + " = " + strEventCode paramList.innertext = "Param1 = " + CStr(Param1) + _ " Param2 = " + CStr(Param2) End SubA 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 SubNow, 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.
- EC_DVD_ANGLE_CHANGE
- EC_DVD_ANGLES_AVAILABLE
- EC_DVD_AUDIO_STREAM_CHANGE
- EC_DVD_BUTTON_CHANGE
- EC_DVD_CHAPTER_AUTOSTOP
- EC_DVD_CHAPTER_START
- EC_DVD_CURRENT_TIME
- EC_DVD_DOMAIN_CHANGE
- EC_DVD_ERROR
- EC_DVD_NO_FP_PGC
- EC_DVD_PLAYBACK_RATE_CHANGE
- EC_DVD_PLAYBACK_STOPPED
- EC_DVD_STILL_OFF
- EC_DVD_STILL_ON
- EC_DVD_SUBPICTURE_STREAM_CHANGE
- EC_DVD_TITLE_CHANGE
- EC_DVD_VALID_UOPS_CHANGE
- EC_DVD_WARNING
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.