Windows Media : Handling Events

Goal: To catch and handle events sent by the Windows Media Player in Internet Explorer. In addition to over 100 properties and more than 20 methods, the Windows Media Player also sends over 20 events.

ITPro Today

February 18, 2002

1 Min Read
ITPro Today logo

Goal: To catch and handle events sent by the Windows Media Player in Internet Explorer. In addition to over 100 properties and more than 20 methods, the Windows Media Player also sends over 20 events. These events allow for a greater level of interactivity between the Media Player and the Web page that hosts it. By listening for and catching events such as the Buffering event, we can handle errors more gracefully and bring data to the user.

Code to Include
Since we're only dealing with event handling in the ActiveX model, we'll start with code that will instantiate the Media Player ActiveX control. We'll deal with the plug-in architecture in a subsequent section..

Next, we'll define a form and some text areas so that we can show what is happening with the client: Now we'll define some event-handling routines. This first one, which handles the MarkerHit event, simply changes the "value" property of a text box to something that the user can understand. In this case, the MarkerHit event is sending a parameter that will specify the number of the current marker of the file. We're then using the GetMarkerName() method to return the name of the marker.

SCRIPT FOR="MediaPlayer1" EVENT="MarkerHit(markerNum)" LANGUAGE="Jscript">myForm.text2.value = MediaPlayer1.GetMarkerName(markerNum)

We'll handle the next event, Buffering, in a slightly different way. Since we cannot access the code in the The code above will call a function in the

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like