Mozilla key events getting lost when player has focus

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
PhatBob
New Cone
New Cone
Posts: 9
Joined: 03 Jan 2008 12:22

Mozilla key events getting lost when player has focus

Postby PhatBob » 03 Jan 2008 17:01

Currently using Firefox 2.0.0.11 on Ubuntu-feisty
The following code allows the user to toggle from the standard embedded 'panel' type of view to the full size of the screen when the user presses the 'm' key.
All works well unless the mouse pointer happens to fall inside the vlc div - in which case 'm' toggles mute. If you move the mouse to the outer edge of the screen (or any point outside the vlc div) events are propagated to the window and the javascript exectutes.

Is this a problem with the embedded VLC player or with Firefox?

* - I was toggling to full screen but the Event problem meant that there was no chance of getting back.

Code: Select all

<html> <head> <script language="Javascript"> var vlc; videoEventKey = { REWIND : 37, VOLUME_UP : 38, FASTFORWARD : 39, VOLUME_DOWN : 40, PLAY_PAUSE : 13, MENU : 77 }; function defaultVideo() { vlc = document.getElementById("vlc"); vlc.playlist.add("file:/usr/local/media/bbc.co.uk.285157478.mpg"); vlc.playlist.play(); document.getElementById("MainBody").focus(); // without this focus remains lost } function cleanUp() { vlc.playlist.stop(); } function skipToSegment(segmentTime) { vlc.input.time = segmentTime; } function toggleMenus() { var menuPanel = document.getElementById("MenuPanel"); var infoPanel = document.getElementById("InfoPanel"); var videoPanel = document.getElementById("VideoPanel"); if (menuPanel.style.display == 'none') { menuPanel.style.display = 'block'; infoPanel.style.display = 'block'; videoPanel.style.width = "1080px"; videoPanel.style.height = "824px"; } else { menuPanel.style.display = 'none'; infoPanel.style.display = 'none'; videoPanel.style.width = "1280px"; videoPanel.style.height = "1024px"; } } function eventHandler(ev) { switch (ev.type) { case 'keydown': switch (ev.keyCode) { case videoEventKey.MENU: toggleMenus(); break; case videoEventKey.REWIND: vlc.input.rate = vlc.input.rate - 1.0; break; case videoEventKey.VOLUME_UP: break; case videoEventKey.FASTFORWARD: vlc.input.rate = vlc.input.rate + 1.0; break; case videoEventKey.VOLUME_DOWN: break; case videoEventKey.PLAY_PAUSE: vlc.playlist.togglePause(); break; } break; } ev.cancelBubble = true; document.getElementById("MainBody").focus(); // without this focus remains lost } </script> <style> div { border-style: solid; border-width: 2px; border-color: #EEF62A; color:#000000; font-family:Arial,Helvetica,sans-serif; font-size:18px; text-align:justify; vertical-align:middle;} .GroupPage { width: 1280px; height: 1024px; position: absolute; top: 0px; left: 0px; } .mPanel { position: absolute; top: 0px; left: 1080px; width: 200px; height: 1024px; background-color:#99CCFF; border:1px solid #FFFFFF; } .vPanel { position: absolute; top: 0px; left: 0px; width: 1080px; height: 824px; } .iP { position:absolute; top:625px; margin-left:50px; height:150px; width:1160px; background-color:#99CCFF; border:1px solid #FFFFFF; } </style> </head> <body id="MainBody" onLoad="defaultVideo();" onKeyDown="eventHandler(event);" onUnload="cleanUp();" > <form id="GroupForm"> <div id="GroupPage" class="GroupPage"> <div id="VideoPanel" class="vPanel"><embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" id="vlc" width="100%" height="100%" loop="yes"></embed></div> <div id="MenuPanel" class="mPanel">Menu Panel</div> <div id="InfoPanel" class="iP">Info Panel</div> </div> </form> </body> </html>

sanjayb
New Cone
New Cone
Posts: 3
Joined: 27 Jan 2008 13:53

Re: Mozilla key events getting lost when player has focus

Postby sanjayb » 27 Jan 2008 14:07

Hi,
My problem is exactly the same - I have a page which uses the VLC player for people to annotate video. There are various Javascript keyboard shortcuts, to mark in points, out points, etc. All works well, except if the mouse is over the VLC player, when the VLC keyboard shortcuts take over (m for mute, space to pause, etc.), and my Javascript keyboard shortcuts no longer work. I tried putting a transparent png in front of the player, also adding an onmouseover event to the embed object with "return false;", but neither approach worked. What I am looking for, simply, is some way to disable all VLC keyboard shortcuts. Would much appreciate some pointer to possible solutions - am not averse to diving into the source code to try and find a way to disable the shortcuts.
Also - a mega-thanks to all the developers - the Javascript API is amazing and we have used it quite a bit for a number of part online, part offline, public art type projects in Bombay and have been able to do some cool things:). I hope the web-plugin project stays alive, and am happy and eager to contribute in any I can (realistically, my skills would possibly be more documentation, etc. rather than hard-core coding).
Cheers, and would appreciate some help with the disabling of keyboard shortcuts.
Many thanks,
Sanjay

Diamanter
New Cone
New Cone
Posts: 6
Joined: 19 Oct 2011 08:49

Re: Mozilla key events getting lost when player has focus

Postby Diamanter » 19 Oct 2011 12:28

I know it's really old topic, but I still have the same problem with newer versions of vlc mozilla plugin and can't find the solution.
Any ideas how to cope with it?

yegor
New Cone
New Cone
Posts: 2
Joined: 26 Oct 2011 16:16

Re: Mozilla key events getting lost when player has focus

Postby yegor » 26 Oct 2011 16:20

Hello, guys!
I have come across the same problem when keyboard events getting lost while mouse over vlc tag.
Does anyone know how to solve this trouble?

Diamanter
New Cone
New Cone
Posts: 6
Joined: 19 Oct 2011 08:49

Re: Mozilla key events getting lost when player has focus

Postby Diamanter » 31 Oct 2011 10:56

Developers, you have to know who's fault is this, Firefox or VLC?
What sources should we look at?

yegor
New Cone
New Cone
Posts: 2
Joined: 26 Oct 2011 16:16

Re: Mozilla key events getting lost when player has focus

Postby yegor » 03 Nov 2011 11:43

Hello.
I have been trying to modify vlc sources to get rid of this annoying problem

Firstly,
I commented RegisterMouseEvents in modules/video_output/xcb/common.c

Code: Select all

/** * Create a VLC video X window object, connect to the corresponding X server, * find the corresponding X server screen. */ vout_window_t *GetWindow (vout_display_t *vd, xcb_connection_t **restrict pconn, const xcb_screen_t **restrict pscreen, uint8_t *restrict pdepth) { ... *pscreen = FindWindow (VLC_OBJECT(vd), conn, wnd->handle.xid, pdepth); if (*pscreen == NULL) { xcb_disconnect (conn); goto error; } //RegisterMouseEvents (VLC_OBJECT(vd), conn, wnd->handle.xid); return wnd; ...
Secondly,
I commented RegisterMouseEvents in modules/video_output/xcb/glx.c

Code: Select all

/** * Probe the X server. */ static int Open (vlc_object_t *obj) { ... xcb_connection_t *conn = XGetXCBConnection (dpy); assert (conn); //RegisterMouseEvents (obj, conn, sys->embed->handle.xid); /* Find window parameters */ ...
Finally,
I commented CreateKeyHandler in modules/video_outout/xcb/window.c

Code: Select all

/** * Create an X11 window. */ static int Open (vlc_object_t *obj) { ... p_sys->conn = conn; //if (var_CreateGetBool (obj, "keyboard-events")) // p_sys->keys = CreateKeyHandler (obj, conn); //else p_sys->keys = NULL; ... /** * Wrap an existing X11 window to embed the video. */ static int EmOpen (vlc_object_t *obj) { ... // if (var_CreateGetBool (obj, "keyboard-events")) // { // p_sys->keys = CreateKeyHandler (obj, conn); // if (p_sys->keys != NULL) // { // const uint32_t mask = XCB_CW_EVENT_MASK; // const uint32_t values[1] = { // XCB_EVENT_MASK_KEY_PRESS, // }; // xcb_change_window_attributes (conn, window, mask, values); // } // } ...


But I still with no result
I would appreciate it if you would point out what other source files I should change.

Thanks


Return to “Web and scripting”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests