Skip to content

vlc.addEventListener does not fire any event

I'm using VLC 1.0.5 with ActiveX and Mozilla Plugin on Windows and Gentoo Linux. On all Systems i register the events listed on http://wiki.videolan.org/Documentation:WebPlugin#Root_object with addEventListener()-Method. But the events get not fired.

Code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/Strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Video</title>
    </head>
    <body topmargin="0" leftmargin="0">
    <script type="text/javascript">
    //<![CDATA[
    if (UserAgent.isIe) {
	document.write('<OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" width="320" height="240" id="player" events="true"></OBJECT>');
    } else {
	document.write('<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="320" height="240" id="player"></embed>');
    }

    var vlc = document.getElementById('player');

    var registerVLCEvent = function(event, handler) {
       if (vlc) {
           if (vlc.attachEvent) {
               // Microsoft
               vlc.attachEvent (event, handler);
           } else if (vlc.addEventListener) {
               // Mozilla: DOM level 2
               //vlc.addEventListener (event, handler, false);
               vlc.addEventListener(event,handler,false);
           } else {
               // DOM level 0
               eval("vlc.on" + event + " = handler");
           }
       }
    }
    // event callback function for testing
    var handleEvents = function (event) {
       alert('event');
       if (!event)
           event = window.event; // IE
       if (event.target) {
           // Netscape based browser
           targ = event.target;
       } else if (event.srcElement) {
           // ActiveX
           targ = event.srcElement;
       } else {
           // No event object, just the value
           alert("Event value" + event );
           return;
       }
       if (targ.nodeType == 3) // defeat Safari bug
           targ = targ.parentNode;
       alert("Event " + event.type + " has fired from " + targ );
    }

    registerVLCEvent('MediaPlayerNothingSpecial', handleEvents);
    registerVLCEvent('MediaPlayerOpening', handleEvents);
    registerVLCEvent('MediaPlayerBuffering', handleEvents);
    registerVLCEvent('MediaPlayerPlaying', handleEvents);
    registerVLCEvent('MediaPlayerPaused', handleEvents);
    registerVLCEvent('MediaPlayerForward', handleEvents);
    registerVLCEvent('MediaPlayerBackward', handleEvents);
    registerVLCEvent('MediaPlayerEncounteredError', handleEvents);
    registerVLCEvent('MediaPlayerEndReached', handleEvents);
    registerVLCEvent('MediaPlayerTimeChanged', handleEvents);
    registerVLCEvent('MediaPlayerPositionChanged', handleEvents);
    registerVLCEvent('MediaPlayerSeekableChanged', handleEvents);
    registerVLCEvent('MediaPlayerPausableChanged', handleEvents);

    var url = 'http://'+window.location.host+'/gui/video.flv';
    vlc.playlist.add(url," ","no-video-title-show");
    vlc.playlist.play();
    //]]>
    </script>
    </body>
    </html>

As you can see, an alert box should appear on video playback, or stop, but nothing is happening. I tried with IE 6,7,8 on Windows XP with VLC ActiveX control, with Firefox 3.5.5 on Windows XP with Mozilla Plugin and with Firefox 3.6.3 on Gentoo Linux. It doesn't work on one of the Browsers.

I took a look into the vlc-plugin source code to find if the event-functions are implemented but i seems that it is not implemented yet. Am I using the wrong VLC version or why isn't the event-handling working?

Regards.

Evil

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information