Page 1 of 1

Capturing mouse clicks

Posted: 16 Nov 2010 17:33
by heng
Hi,

I'm trying to capture a mouse click/dblclick while playing a video file. My goal is, for example, to maximize the display window when the user double click on the video screen (btw "libvlc_toggle_fullscreen" no longer work with libvlc v1.1.x).

How can I do that? I thought about using the "libvlc_event_attach" function but I don't see any mouse event types in "libvlc_event_e".

Please advise.

Re: Capturing mouse clicks

Posted: 17 Nov 2010 19:49
by mangokm40
Give details about your development environment. Also, use the search function. You are not the first to ask this question.

Re: Capturing mouse clicks

Posted: 17 Nov 2010 20:38
by XilasZ
There is libvlc_video_set_mouse_input (new in v1.1), to enable/disable mouse handling by vlc.

But i think the best way to handle mouse/key input is to handle them yourself in your app. Embed the video frame in your GUI and handle mouse events from the GUI, not vlc.

Re: Capturing mouse clicks

Posted: 17 Nov 2010 23:18
by rogerdpack
viewtopic.php?f=32&t=73100 might help (but I think XilasZ is right there...)

Re: Capturing mouse clicks

Posted: 18 Nov 2010 08:08
by heng
I AM using the "libvlc_video_set_mouse_input" but I don't recieve any doubleclick events in the containing parent window (I tried both enable/disable mouse input). If I replace the VLC control with an image control (ATL CImage) I get those events easily. Any idea why is that?

I am using libvlc 1.1.5 in VS2010 with MFC under Windows 7.

Is there a way to make libvlc invoke my callback when mouse click happen, like I am currently doing with the "libvlc_event_attach" function for capturing "libvlc_MediaPlayerTimeChanged" events?

Re: Capturing mouse clicks

Posted: 18 Nov 2010 09:10
by XilasZ
it's normal, libvlc_video_set_mouse_input(true) will tell libvlc that it can capture mouse and react to it, but it won't interact with your program.
The issue is that libvlc capture the mouse and keep it for itself, so your app won't see any mouse activity.
try to use libvlc_video_set_mouse_input(false), see if it allows your program to capture the mouse.

A little tips that i used to do that in wpf 3.5 (before libvlc_video_set_mouse_input was added) : i disabled the host control which contains the vlc frame, so mouse event will never reach vlc, allowing me to handle the mouse my way. But it might be related to the necessary mix between wpf and winforms (as vlc need a handle to the display surface, which doesn't exist in wpf).

Re: Capturing mouse clicks

Posted: 18 Nov 2010 13:35
by lanamelach
Have the same question. You said "Embed the video frame in your GUI and handle mouse events from the GUI, not vlc". What does it mean? I am rendering video to Gtk::DrawingArea and it doesn't receive any messages the same as other parent controls of that DrawingArea. Could someone explain how to receive click messages from vlc?

Re: Capturing mouse clicks

Posted: 18 Nov 2010 15:21
by rogerdpack
the above links and discussion might help...

Re: Capturing mouse clicks

Posted: 18 Nov 2010 18:11
by Rémi Denis-Courmont
Have the same question. You said "Embed the video frame in your GUI and handle mouse events from the GUI, not vlc". What does it mean?
It means it's best to disable LibVLC keyboard and mouse events with libvlc_set_key_input(false) and libvlc_set_mouse_input(false). Then the X server will pass the events to the parent widget that VLC is drawing to, which belonds to your application.

Re: Capturing mouse clicks

Posted: 06 Sep 2011 14:49
by lanamelach
But if I use libvlc_set_mouse_input(false) I won't be able to click on DVD menu. I think there must be some way to receive mouse events before VLC eats them. Why not to provide a function that allows to install a user callback to filter/preprocess events?

Re: Capturing mouse clicks

Posted: 06 Sep 2011 15:35
by Rémi Denis-Courmont
This is not easy to implement. Besides, I believe there is no way to determine whether an area of the video is "active" in some way, or not.

So if you want to catch mouse clicks, for instance to pause the video à la Adobe Flash, then forget DVD menus... The two are more or less mutually incompatible. That is why VLC media player does not use the mouse like Adobe Flash in the first place.

Re: Capturing mouse clicks

Posted: 06 Sep 2011 16:00
by lanamelach
This is not easy to implement.
Really? I don't know how it is implemented, but if you know that a user clicked on the window why not to call a filter function before doing what it now does? e.g.:

Code: Select all

void vlc_mouse_receiving_function(MouseEventInfo *info) { if (userCallback(info)) eatMouse(); // use mouse event here else ; // do Nothing }
Besides, I believe there is no way to determine whether an area of the video is "active" in some way, or not.
It is up to a user to determine what is active or not. I want to show popup menu for video area for right click and toggle full screen on left button double click. By the way, VLC player itself does it and DVD menu works there.

Re: Capturing mouse clicks

Posted: 06 Sep 2011 16:11
by Rémi Denis-Courmont
This is not easy to implement.
Really? I don't know how it is implemented,
First it depends on the platform. And then it is typically from the video rendering thread.

But if you think it's easy, you're welcome to propose a patch.
Besides, I believe there is no way to determine whether an area of the video is "active" in some way, or not.
It is up to a user to determine what is active or not. I want to show popup menu for video area for right click and toggle full screen on left button double click. By the way, VLC player itself does it and DVD menu works there.
VLC does not filter events. It just dispatches them to both the DVD menu VM and the UI. It so happens that the UI handling was designed to not conflict with DVD menus: a single left click has no effects in the VLC UI.

If your application reacts on left mouse clicks, then DVD menus will not work anyhow.