Javascript / Jquery Problem with - playStateChange, Mediaplayer object IE9 ... trying to get Jquery bind () to work on this event ... Read On

Ok, now the problem is here.

At first I tried to exclude whether to use a flash player for the html5 player or a media player for this client ..... HTML5 seems to offer an implementation that is a plugin, so I decided to abandon Flash ... and considered the HTML5 route ... everything is fine ... made a good player, which was also a cross browser and took good care of the codecs, but oops ... I realized that html5 could not transfer ASX ... so I returned to the old media player screen. I had no real choice ....

I put a javascript function that is just a warning and should fire whenever the media player changes state (say, you pause it from playing ....)

function WMP_status() { alert("state Changed"); } 

I included a media planner object in an html page, and I created an alias in javascript to access this object programmatically and gain control over it through javascript ... Like this ....

 var WMP=document.getElementById("mediaplayer"); 

Then it was the turn to capture the state of the media player ... so I needed some form of event ... so I recorded the event like that ... and worked great ...

 WMP.attachEvent("playStateChange", WMP_status); // Note ... WMP.detachEvent("playStateChange", WMP_status); ... doesn't always detach events... 

I, that in IE the problem of events that do not separate still persisted (go figure), but to my surprise, I realized that with ie9 .... addEventListener should also be included as part of javascript support, so I tried the next line, which should obviously be above, but without joy .....

 WMP.addEventListener("playStateChange", WMP_status , false); 

Perhaps I thought that addEventListener was not properly implemented in IE9, so I tried to use the jQuery bind () method, for example ... but still not a joy ....

 $(WMP).bind("playStateChange", WMP_status); 

I tried these 2 options

(a) there is still no joy ....

 $(WMP).bind("playStateChange", "WMP_status"); 

(b) there is still no joy .....

 $(WMP).bind("playStateChange", function(){WMP_status()}); 

I tried this to eliminate all kinds of possibilities ... there was no information on the jquery site about whether I can specify the name of the function or not ... so I tried to enable anonymous ...

In any case ... I would rather use the Jquery engine to handle events, especially because of this much more cross-browser ... can anyone help me with this? I also posted this route of dynamically related events, because I will add / remove elements using jquery ... and remove () will also remove events easily ...

Many thanks al

+4
source share
1 answer

In accordance with this site, binding to a wmp plugin using a javascript library, for example jQuery, will not work due to a missing on prefix, it will read "onPlayStateChange"), which is usually a prefix of all event names.

Libraries such as jQuery accept this rule in the account ... and actually register in a nonexistent event.

If so, then you need to stay with attachEvent

+1
source

All Articles