MouseListener not workigng when while video playing

This forum is about all development around libVLC.
aneeshsebastian
Blank Cone
Blank Cone
Posts: 18
Joined: 16 May 2011 08:03

MouseListener not workigng when while video playing

Postby aneeshsebastian » 13 Apr 2013 11:13

I have a JPanel to which a EmbeddedMediaPlayerComponent is embedded. I added the following listener

mediaPlayerComponent.addMouseListener(new MouseListener() {

@Override
public void mouseReleased(MouseEvent e) {
System.out.println("Mouse Released..Aneesh");
}

@Override
public void mousePressed(MouseEvent e) {
System.out.println("Mouse Pressed..Aneesh");
}

@Override
public void mouseExited(MouseEvent e) {
System.out.println("Mouse Exioted..Aneesh");
}

@Override
public void mouseEntered(MouseEvent e) {
System.out.println("Mouse Entered..Aneesh");
}

@Override
public void mouseClicked(MouseEvent e) {
System.out.println("Mouse Clieck..Aneesh");
}
});
MouseEvent working perfectly unitl video play starts. But once video play started mouseEvent is not getting generated. Am I missing something?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: MouseListener not workigng when while video playing

Postby sherington » 13 Apr 2013 12:13

You are not providing quite enough information to help you.

Presumably you are using Windows - this works just fine on Linux but it is simply not possible to get those events on Windows - unless you use the custom WindowsCanvas implementation. This is a pretty bad solution since it involves installing a global native message hook, nevertheless it dose work.

So read the Javadoc for WindowsCanvas, and if you're using an EmbeddedMediaPlayerComponent look at the onGetCanvas() overridable method.

aneeshsebastian
Blank Cone
Blank Cone
Posts: 18
Joined: 16 May 2011 08:03

Re: MouseListener not workigng when while video playing

Postby aneeshsebastian » 13 Apr 2013 12:23

Thanks for the reply.

I already did it.But it did not help me. MouseListener not getting picked up while video is playing @ canvas

aneeshsebastian
Blank Cone
Blank Cone
Posts: 18
Joined: 16 May 2011 08:03

Re: MouseListener not workigng when while video playing

Postby aneeshsebastian » 13 Apr 2013 12:43

My application is expected to run in Windows. Does this not at all possible in Windows?What's the reason? Bz of Canvas implementation in windows? Or is the thr problem with VLCJ APIs. Why we still use Canvas instead of JPanel. Can't we change implementation?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: MouseListener not workigng when while video playing

Postby sherington » 13 Apr 2013 13:40

My application is expected to run in Windows. Does this not at all possible in Windows?What's the reason? Bz of Canvas implementation in windows? Or is the thr problem with VLCJ APIs. Why we still use Canvas instead of JPanel. Can't we change implementation?
Of course vlcj+libvlc works in Windows. Some features however work to a limited extent, that's simply the reality of dealing with native code. The mouse listener stuff is something that on Windows requires a native Windows event hook - it's pretty nasty, but it does work.

JPanel is lightweight - it is not a "real" window. Native code needs a handle on a "real" heavyweight window so it knows where to render the video to, hence Canvas. That is not a "problem" with the vlcj API - JOGL and other toolkits work in the same way.

You *can* render into JPanel if you do your own software rendering with DirectMediaPlayer, but there are obvious performance implications of doing it this way.

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: MouseListener not workigng when while video playing

Postby Rémi Denis-Courmont » 13 Apr 2013 14:23

Does this not at all possible in Windows?
As far as I am aware, nobody really checked what was just implementation gap in VLC for Windows and what would be fundamental limitations of the Microsoft Windows API. I don't know.
What's the reason?
When I redesigned and rewrote the X11 event handling, I specifically considered both VLC and LibVLC use cases. To my knowledge, when the Windows event handling was rewritten, only VLC was considered.
Bz of Canvas implementation in windows? Or is the thr problem with VLCJ APIs. Why we still use Canvas instead of JPanel. Can't we change implementation?
I would fault the lack of involvement of Windows developers in LibVLC development, rather than any particular component.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

aneeshsebastian
Blank Cone
Blank Cone
Posts: 18
Joined: 16 May 2011 08:03

Re: MouseListener not workigng when while video playing

Postby aneeshsebastian » 13 Apr 2013 15:06

Thanks for your reply.

I'm just wondering if it worthy to put some effort for native Windows event hook implementation. If it's not I should do with a different design where mouse events from video playing canvas not being captured.

Because of curiosity, what could be the real problem here? Native libraries are not capturing mouse events while video being played? Or it captures , but not getting it back to JAVA API where events are registered.

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: MouseListener not workigng when while video playing

Postby sherington » 13 Apr 2013 17:03

I'm just wondering if it worthy to put some effort for native Windows event hook implementation.
The hook implementation is already there for you in the WindowsCanvas. Last time I tested it, it worked for me.

Out of interest, what is your use-case for needing those mouse events?

You might be able to use a transparent Window overlay and grab the mouse events from that (kind of like a GlassPane), but that has it's own issues...

aneeshsebastian
Blank Cone
Blank Cone
Posts: 18
Joined: 16 May 2011 08:03

Re: MouseListener not workigng when while video playing

Postby aneeshsebastian » 16 Apr 2013 12:07

Thanks for the details. WindowsCanvas worked for me. Now I'm able to capture mouse events.

Sherington :I had to capture mouse event to show VIdeoControl panel while mouse pointer is there in WindowsCanvas.

But now a new problem as Canvas getting resized when video control panel hides upon receiving mouse event

aneeshsebastian
Blank Cone
Blank Cone
Posts: 18
Joined: 16 May 2011 08:03

Re: MouseListener not workigng when while video playing

Postby aneeshsebastian » 18 Apr 2013 15:12

I have realized that WIndowsCanvas API is unstable. Event capturing is not consistent. I already spent 4 days to work on this. API documentation says "This class is experimental, unsupported and unstable in operation."

Is it worth to still work on this?

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: MouseListener not workigng when while video playing

Postby Rémi Denis-Courmont » 18 Apr 2013 17:42

Someone who cares and knows about Windows, should check if this limitation cannot be fixed cleanly in the VLC video outputs. I am not volunteering.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 6 guests