Search code examples
javascripthtmlinternet-exploreractivexwindows-media-player

Double Click Event Not Fired on Playing Windows Media Object in IE


I'm working on a media player where I'm using the Windows Media ActiveX object to play video, and I need to know when the video goes full screen. I can't find a full screen event, so I'm having to find a workaround. As part of the work around, I need to be able to get (and preferably intercept) the double click event which makes the media player go full screen, but I can't get the event when the player has started playing, presumably because the player takes it to be able to know when to go full screen.

I've tried many different things to get the event while it's playing:

activeXElement.attachEvent('ondblclick',function(){alert('Double Click')});
activeXElement.attachEvent('dblclick',function(){alert('Double Click')});
activeXElement.attachEvent('ondoubleclick',function(){alert('Double Click')});
activeXElement.attachEvent('doubleclick',function(){alert('Double Click')});
activeXElement.attachEvent('DoubleClick',function(){alert('Double Click')});
activeXElement.attachEvent('onDoubleClick',function(){alert('Double Click')});
activeXElement.attachEvent('OnDoubleClick',function(){alert('Double Click')});
activeXElement.ondblclick=function(){alert('Double Click')};
activeXElement.dblclick=function(){alert('Double Click')};
activeXElement.ondoubleclick=function(){alert('Double Click')};
activeXElement.doubleclick=function(){alert('Double Click')};
activeXElement.DoubleClick=function(){alert('Double Click')};
activeXElement.onDoubleClick=function(){alert('Double Click')};
activeXElement.OnDoubleClick=function(){alert('Double Click')};

When it hasn't started playing, the following two work:

activeXElement.attachEvent('doubleclick',function(){alert('Double Click')});
activeXElement.attachEvent('DoubleClick',function(){alert('Double Click')});

None of them are working when it is playing. Does anybody have any ideas on how to get a double click event on the ActiveX object when it is playing?


Solution

  • I ended up creating a workaround for this issue. I'm posting it here for others that may run into this problem.

    I listen for the click event, and when the element is clicked, hide the controls like I wanted to when it went fullscreen. Then, later (give time for a double-click), check if it is full screen, and, if it isn't hide the controls again. I had to show the controls temporarily because I can't hide or show the controls once it's fullscreen.

    Here is the code I used:

    activeXElement.attachEvent('click',
        function(nButton){
            if(nButton!=1)return;// Not  left click
    
            // I can't set uiMode when full screen.
            // Set it now and set it back later if needed.
            activeXElement.uiMode='full';
            setTimeout(
                function(){
                    if(activeXElement.fullScreen){
                        // It went full screen.
                        // Do some stuff...
                    }
                    else activeXElement.uiMode='none';
                }
            ,750);
        }
    );