Page 1 of 2

vlc.addEventListener does not fire any event

Posted: 08 Jun 2010 16:49
by Evil.2000
Hi!

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: ... oot_object with addEventListener()-Method. But the events get not fired.

Here's the code i use:

Code: Select all

<!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"> <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="320" height="240" id="player"></embed> <script type="text/javascript"> //<![CDATA[ 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

Re: vlc.addEventListener does not fire any event

Posted: 09 Jun 2010 08:15
by thanaos
I have the same pb !

Re: vlc.addEventListener does not fire any event

Posted: 10 Feb 2011 08:46
by jack.ting
Hi, there:

I found that the FireFox bowser has trouble on "addEventListener()" function.
The vlc.addEventListener does exist, but the Event Handler can not registered successfully, so...
You've to fall back to DOM Level 0.
Modily the registerVLCEvent() function as follow, pls.

Code: Select all

var registerVLCEvent = function(event, handler) { if (vlc) { if (vlc.attachEvent) vlc.attachEvent (event, handler); else eval("vlc.on" + event + " = handler"); } }

Re: vlc.addEventListener does not fire any event

Posted: 24 Mar 2011 13:58
by cabana80
Hi jack.ting,

I managed to register the "MediaPlayerEndReached" event in IE9 with VLC 1.1.5, but not in Firefox 4. In Firefox I tried all of the following:

vlc.MediaPlayerReached = doNext;
vlc.onMediaPlayerReached = doNext;
vlc['MediaPlayerReached'] = doNext;
vlc['onMediaPlayerReached'] = doNext;

Where doNext() is a function as in your other example here: viewtopic.php?t=84279#p286741.

Could you please confirm that you were able to register the DOM event in Firefox? If so, what versions of Firefox and VLC did you use? Could you also provide a short sample code of the exact event listener call?

Thanks!

Re: vlc.addEventListener does not fire any event

Posted: 13 Jun 2011 06:04
by jack.ting
Hi cabana80,

Sorry, for late respond.

I use still using 3.6.15.
the complete example as the following

Code: Select all

function regVLCEvent(tobj, type, func) { if (tobj.attachEvent) tobj.attachEvent(type, func); // else if (tobj.addEventListener) // tobj.addEventListener(type, func, true); else tobj["on" + type] = func; } ... var my_vlc = new Object(); ... my_vlc = document.getElementbyId('vlc_id'); ... regVLCEvent(my_vlc, 'MediaPlayerEndReached', doNext);
so, it should be simular to the 4th of your tries.

Re: vlc.addEventListener does not fire any event

Posted: 19 Jul 2011 09:30
by Yansky
Are the event handlers still not implemented in the Mozilla version of the plugin?

Re: vlc.addEventListener does not fire any event

Posted: 20 Dec 2011 16:03
by jml674
Hello, I'm currently trying to understand what's going on with on with the AddEventListener method of the 1.1 plugin with FIREFOX.
A few preliminary remarks:
- it does not fire the handler you specify although most of the code seems to work fine.
- for a successful registration , you need to have the player playing (that was not obvious to me).
Note: you should not rely on any other method than "player.addEventListener("

I have not studied the ActiveX version due to lack of compilation environment and will not.

Re: vlc.addEventListener does not fire any event

Posted: 21 Dec 2011 16:10
by JustinWyllie
I'm told by my c developer that the events system was added as a patch but then 'unimplemented' by the main developers. It does not work.

Re: vlc.addEventListener does not fire any event

Posted: 22 Dec 2011 14:33
by jml674
Not sure. Troubleshooting the code, I was able to evidence:
- the events are properly registered in the vlc internal structure
- they are properly fired within vlc thread
- however and despite the fact the propper callback function address is used when the event fires, the call has not effect within the firefox environment ie the javascript handler is not called.

Re: vlc.addEventListener does not fire any event

Posted: 24 Dec 2011 08:37
by RSATom
added support of addEventListener to windows version:
http://mailman.videolan.org/pipermail/v ... 84379.html

builded version:
http://code.google.com/p/vc-axnp-vlc/downloads/list

Re: vlc.addEventListener does not fire any event

Posted: 07 Jan 2012 11:10
by jml674
Thanks Sergey !

Re: vlc.addEventListener does not fire any event

Posted: 07 Jan 2012 12:37
by RSATom
you are wellcome!

Re: vlc.addEventListener does not fire any event

Posted: 22 Feb 2012 07:10
by Mark Lesha
We are using the VLC 2.1.0 Mozilla plugin with Firefox, and we noted the same problem. i.e. we cannot get event handlers to register clicks on the embedded video image in the browser. This would be really useful to us, since we could use it to place markers on the incoming video, etc.

Your patch sounds really good. But I think we need an updated npvlc.dll for Firefox, instead of axvlc.dll (which is for IE). Am I right?

I'm not sure if we could be clever enough to set up our own source builds, but I guess we could try :)

Will your patch find its way into the 2.1.0 nightly builds some time?

Re: vlc.addEventListener does not fire any event

Posted: 22 Feb 2012 07:35
by Mark Lesha
I forgot to mention, we are running Windows XP, and Firefox 10 with VLC 2.1.0 nightly build from 18/02/12

Re: vlc.addEventListener does not fire any event

Posted: 22 Feb 2012 09:22
by RSATom
this patch already applied, but it's not related to catching mouse events in JS. At this time there are no way to catch mouse clicking.

Re: vlc.addEventListener does not fire any event

Posted: 27 Feb 2012 05:58
by drdim
Hello!

Thanks for fixing "addEventListener" !

But, There is a lack of "volumechange" event:
volume can be changed or muted throught plugin controls or with keyboard/mouse and from javascript i want to know when volume is changed. Currently, i do it checking vlc.audio.volume periodically, but listening "volumechange" will be more good solution.

Re: vlc.addEventListener does not fire any event

Posted: 27 Jul 2012 23:14
by Tuizi
Today, what is the solution to catch the event "MediaPlayerOpening" on Chome?
The solution of the custom ActiveX doesn't work, and the official version doesn't too.

Thank you for your help :D

Re: vlc.addEventListener does not fire any event

Posted: 28 Jul 2012 04:00
by RSATom

Re: vlc.addEventListener does not fire any event

Posted: 29 Jul 2012 03:55
by Tuizi
Events only work with Firefox with FBVLC too.... :(

Re: vlc.addEventListener does not fire any event

Posted: 29 Jul 2012 05:18
by RSATom
hm... it's very strange... all events does not work or only some of them?

Re: vlc.addEventListener does not fire any event

Posted: 29 Jul 2012 08:03
by Tuizi
It's OK! :) It's work... a little... I'm searching what is the problem, what is wrong...

For exemple if I launch file:///C:/demo/FBVLC_0.0.0.6.htm it's ok, but If a lauch the same file by http:// (http://localhost/demo/FBVLC_0.0.0.6.htm) I'll get an error:

Code: Select all

Error in event handler for 'undefined': Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined at X (eval at <anonymous> (chrome-extension://phahnhbgfdhgobenebnjbgmacgpbfaag/includes/wombat_content.js:11:30)) at Ka (eval at <anonymous> (chrome-extension://phahnhbgfdhgobenebnjbgmacgpbfaag/includes/wombat_content.js:11:30)) at eval at <anonymous> (chrome-extension://phahnhbgfdhgobenebnjbgmacgpbfaag/includes/wombat_content.js:11:30) at eval at <anonymous> (chrome-extension://phahnhbgfdhgobenebnjbgmacgpbfaag/includes/wombat_content.js:11:30) at miscellaneous_bindings:283:9 at [object Object].dispatch (event_bindings:203:41) at Object.<anonymous> (miscellaneous_bindings:250:22)

Re: vlc.addEventListener does not fire any event

Posted: 29 Jul 2012 18:06
by Tuizi
In first time, thank you for your plugin FBVLC, it's perfect ;)
I have one last question, how switch to fullscreen? The toggleFullscreen method doesn't work.

Re: vlc.addEventListener does not fire any event

Posted: 29 Jul 2012 18:12
by RSATom
fullscreen works now only in windowed mode

Re: vlc.addEventListener does not fire any event

Posted: 29 Jul 2012 20:50
by Tuizi
With toggleFullscreen method? how?

Code: Select all

TypeError: Property 'toggleFullscreen' of object <JSAPI-Auto Javascript Object> is not a function

Re: vlc.addEventListener does not fire any event

Posted: 30 Jul 2012 03:32
by RSATom
Maybe it's a bug. I'll check. Anyway, you can use double clicking on player area.