title: Javascript / Jquery Problem with - playStateChange , Mediaplayer object IE9 ... trying to make Jquery bind() work on this event ...Read On
body: <p>Ok now the problem is here ....</p>
  
  <p>I first was trying to rule out whether to use a flash player an html5 player or a mediaplayer for this client ..... HTML5 seems to be offering implementation which is plugin free so i decided to opt out on Flash .... and was considering the HTML5 route ... all fine ... did a nice player which was also cross browser and took good care of the codecs but oops ... realised html5 was not able to stream ASX ... so it was back to the old windows mediaplayer route .... I had no real choice....</p>
  
  <p>I put a javascript function which is just an alert and should be triggered whenever the mediaplayer changes state (say from play you pause it .... ) </p>
  
  <pre><code>function WMP_status()
  {
     alert("state Changed");
  }
  </code></pre>
  
  <p>I embedded a mediaplayer object on an html page and i created an alias in javascript to access that object programatically and gain control over it via javascript ......Like so ....</p>
  
  <pre><code>var WMP=document.getElementById("mediaplayer");
  </code></pre>
  
  <p>Then it was the turn of capturing the state of the mediaplayer ... so I required some form of event ... so I registered the event like so ....and worked fine...</p>
  
  <pre><code>WMP.attachEvent("playStateChange", WMP_status);
  // Note ...  WMP.detachEvent("playStateChange", WMP_status); ... doesn't always detach events...
  </code></pre>
  
  <p>I that in IE the problem of events not detaching still persisted (go figure) but to my surprise I realised that as of ie9 .... the addEventListener should have been also included as part of the javascript support so i tried the following line which should apparently stand for the above but no joy .....</p>
  
  <pre><code>WMP.addEventListener("playStateChange", WMP_status , false); 
  </code></pre>
  
  <p>I maybe thought that addEventListener was not still properly implemented in IE9 so I tried to use the JQuery bind() method like so .... but still no joy ....</p>
  
  <pre><code>$(WMP).bind("playStateChange", WMP_status); 
  </code></pre>
  
  <p>I tried also these 2 variants </p>
  
  <p>(a) still no joy ....</p>
  
  <pre><code>$(WMP).bind("playStateChange", "WMP_status"); 
  </code></pre>
  
  <p>(b) still no joy .....</p>
  
  <pre><code>$(WMP).bind("playStateChange", function(){WMP_status()}); 
  </code></pre>
  
  <p>I tried these to eliminate all sorts of possibilities ... there was no info on the jquery site whether i could put in a function name or not ... so i tried putting in an anonymous one as well....</p>
  
  <p>Anyways ... I'd really prefer to use the Jquery mechanism for event handling especially because of it's much more cross browser ... can anyone please help me on this one? I also went this route of dynamically attaching events because I will be adding / removing elements via jquery ... and remove() would also detach events conveniently ...</p>
  
  <p>Many Thanks 
  Al</p>