Windows Media : Handling Events Cross-Browser

Description: Goal- To catch and handle events sent by the Windows Media Player using both Microsoft Internet Explorer's ActiveX model and Netscape Navigator's Plug-in model.

Netscape Navigator's plug-in model does not allow events to be handled as easily as Internet Explorer's. Creating code to work with both Navigator and Explorer is often a difficult task. This sample gives a good taste of the kinds of code necessary to handle events across both formats.

More Details

In Navigator, we use the appObs proxy applet to send callback methods to the Media Player plug-in. This Java applet resides on the page, and "listens" to all of the events that the Media Player sends out. The applet itself can be installed on a page with the following code:
Before an event is fired, an event observer must be enabled to trap the event. The following code segment illustrates how to enable event observers:

appObs.setByProxyDSEventNameObserver(plugin, true);

Each registered event observer requires a corresponding event handler. In JavaScript for Netscape Navigator, an event handler is declared using the following syntax:
function OnDSEventNameEvt (paramter, ...) { // code goes from here.. }
In the above snippets, EventName is the Media Player event that is being handled. You simply need to replace this with the name of the Media Player event that you wish to listen to. Once the appObs applet instantiates, we need to set it to listen to browser events. In this sample, we're only going to be using the PlayStateChange event, and we'll do this when the page loads. First, we must call the appropriate function when the browser sends the onload event:


The following bit of code, which goes inside the main The doPlayStateChanges function will be defined in the main

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish