• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1140
  • Last Modified:

Firefox does not handle Windows Media Player events

Hi,

I want to use a windows media player in a web page, to be used in Firefox browser.
while all the controls' events are handled, the windows media player are not handled.
I used the following code :

<SCRIPT language="JavaScript" type = "text/JavaScript">
   var MediaPlayer = document.getElementById("MediaPlayer");
   if (MediaPlayer.addEventListener)
     MediaPlayer.addEventListener("click",function(e) {alert("click"); },true); // does not work
   if (window.addEventListener)
     window.addEventListener("click",function(e) {alert("click"); },true); //  works well.

</SCRIPT>

<object id = "MediaPlayer" ...>
  <param = "..." value = "...">
</object>

I tried to install the media player plugin, but it didn't help.

Please tell me how to solve this problem.

Thanks
Michael
0
MichaelMarom
Asked:
MichaelMarom
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
Your code has to be after the object:

(code from http://www.captain.at/howto-addeventlistener-attachevent-parameters.php)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <title>Untitled</title>

<SCRIPT language="JavaScript" type = "text/JavaScript">
function initPage() {
  object = document.getElementById("MediaPlayer");
  if(window.addEventListener){ // Mozilla, Netscape, Firefox
        object.addEventListener('mouseover', testevent, false);
        object.addEventListener('click', testevent, false);
        object.myflag = "test";
        object.mydata = "123";
  } else { // IE
        object.attachEvent('onmouseover', testevent);
        object.attachEvent('onclick', testevent);
        object.myflag = "test";
        object.mydata = "123";
  }
}  

function testevent(evt){
      var e_out;
      var ie_var = "srcElement";
      var moz_var = "target";
      var prop_var = "id";
      // "target" for Mozilla, Netscape, Firefox et al. ; "srcElement" for IE
      evt[moz_var] ? e_out = evt[moz_var][prop_var] : e_out = evt[ie_var][prop_var];
      alert(e_out);
      prop_var = "mydata";
      evt[moz_var] ? e_out = evt[moz_var][prop_var] : e_out = evt[ie_var][prop_var];
      alert(e_out);
}
</SCRIPT>
 
</head>

<body onLoad="initPage()">


<object id="MediaPlayer" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" type="application/x-oleobject"
       codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
        standby="Loading Microsoft Windows Media Player components..."
        width="320" height="67">
         <param name="url" value="http://members.aol.com/jrzycrim01/music/Bullethead.mp3">
         <param name="autostart" value="false">
         <param name="ShowStatusBar" value="true">
         <param name="volume" value="100">
         <p>
          ActiveX is not installed or is not working properly.
          If you are using Firefox, please refer to the following Guide:
          <a href="http://forums.mozillazine.org/viewtopic.php?t=206213">

           Embedded Windows Media in Firefox
          </a>
         </p>
       </object>
</div></body>
</html>
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now