Problem receiving clicks on VLC video window

125 views
Skip to first unread message

Alec Bennett

unread,
Oct 25, 2018, 11:28:09 AM10/25/18
to wxpytho...@googlegroups.com
I'm using libVLC to play a video, and trying to detect when the video window is clicked. It works fine on a Windows XP machine, but not on a machine with an identical Python setup running Windows 7...

Both are running Python 2.7 and wxPython 2.8.

I tried with wxPython 4.0.3 (latest version on pip), but same behavior.

I posted a very stripped down version with a test video and the vlc.py binding here:


Note that libVLC has a parameter called "video_set_mouse_input(0)" that when enabled shows a debug message when the VLC window is clicked, and doesn't show the message when disabled. So it works, but isn't passing the clicks to the main window on Windows 7. On the XP box the main window receives the clicks regardless of video_set_mouse_input(). 

Also note that I'm giving the video panel the "wx.WANTS_CHARS" style to receive keyboard input. This works, maybe there's something similar for mouse clicks?

And note that this requires VLC version 3+ to be installed.

Here's the sample code (same as at the link above):

#! /usr/bin/python

import os, sys, time 
import vlc
import wx 
print "wxPython version %s" % wx.version()

current_directory = os.path.dirname(os.path.realpath(__file__))

class Player(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, -1, "VLC Test",
                          pos=wx.DefaultPosition, size=(850, 560))

        self.program_launch_time = time.time()
        self.video_initted = False

        self.Bind(wx.EVT_CLOSE, self.onExit)

        self.videopanel = wx.Panel(self, -1, style= wx.WANTS_CHARS)

        # working only with VLC lib v3+ on XP... Not Win7...
        self.videopanel.Bind(wx.EVT_LEFT_DOWN, self.onVideoPress)
        self.videopanel.Bind(wx.EVT_LEFT_UP, self.onVideoRelease)

        # trying to bind another way...
        #self.Bind(wx.EVT_LEFT_DOWN, self.onVideoPress, self.videopanel)

        self.sizer2 = wx.BoxSizer(wx.VERTICAL)
        self.sizer2.Add(self.videopanel, 1, flag=wx.EXPAND) 

        self.SetSizer(self.sizer2)
        self.SetMinSize((600, 400))

        # finally create the timer. 
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
        self.timer.Start(50)
       
        # VLC player
        options = ""
        options += "--sub-source marq " # enable the marquee printing
        options += "--no-video-title " # not sure if does anything
        options += "--verbose=2 " # lots of output (-1 is no output)
        self.vlcInstance = vlc.Instance(options) # this lets me write to the VLC marquee...
        self.player = self.vlcInstance.media_player_new()

    def onVideoPress(self, event):
        print "clicked!"
        event.Skip()

    def onVideoRelease(self, event):
        print "mouse released!"
        event.Skip()
        
    def onPlay(self, evt):

        path = os.path.join(current_directory, "test.mp4")
        self.Media = self.vlcInstance.media_new(unicode(path))
        self.player.set_media(self.Media)
     
        # VLC receive mouse clicks?
        self.player.video_set_mouse_input(0)

        # set the window id to render VLC's video output
        handle = self.videopanel.GetHandle()
        if sys.platform.startswith('linux'): self.player.set_xwindow(handle)
        elif sys.platform == "darwin": self.player.set_nsobject(handle)            
        else: self.player.set_hwnd(handle)
        self.player.play()
        return

    def onTimer(self, event):            
           
        # on Ubuntu, if I init the video right away it launches in a separate window.
        if (time.time() - self.program_launch_time > 1) and not self.video_initted:
            self.video_initted=True
            self.onPlay(None) 

    def onExit(self, evt):
        os._exit(1)

if __name__ == "__main__":
    #app = wx.PySimpleApp()
    app = wx.App()
    player = Player()
    player.Centre()
    player.Show()
    app.MainLoop()



wrybread

unread,
Oct 25, 2018, 7:27:44 PM10/25/18
to wxPython-users
I just tested on an Ubuntu machine with wxPython version "3.0.2.0 gtk2 (classic)" and VLC version "2.2.6 Umbrella" and it works fine, I'm able to detect the clicks on the video. 

Still stumped for Windows 7. Haven't tested in Windows 8 or 10 yet.


Mario Lacunza

unread,
Oct 25, 2018, 7:31:54 PM10/25/18
to wxpytho...@googlegroups.com
LOL Win 7?? that thing is reached his EOL a lot of time ago..

Saludos / Best regards

Mario Lacunza
Email:: mlac...@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Skype: mlacunzav

Lima - Peru


El jue., 25 de oct. de 2018 a la(s) 18:27, wrybread (wryb...@gmail.com) escribió:
I just tested on an Ubuntu machine with wxPython version "3.0.2.0 gtk2 (classic)" and VLC version "2.2.6 Umbrella" and it works fine, I'm able to detect the clicks on the video. 

Still stumped for Windows 7. Haven't tested in Windows 8 or 10 yet.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wrybread

unread,
Oct 25, 2018, 7:40:33 PM10/25/18
to wxPython-users
On Thursday, October 25, 2018 at 4:31:54 PM UTC-7, Mario Lacunza wrote:
LOL Win 7?? that thing is reached his EOL a lot of time ago..

Supported until 2020 and still widely used.


Probably same issue in Windows 10 but I don't have a Win10 machine to test on. Curious to hear if it has the same issue there, if anyone does test.

wrybread

unread,
Oct 29, 2018, 1:34:09 AM10/29/18
to wxPython-users
Confirmed, Windows 10 isn't receiving clicks on a VLC video window either.

To recap, that means on Ubuntu I'm able to receive clicks on a VLC window, but not with identical setups on Windows 7 or Windows 10. For whatever it's worth, on a Windows XP box with the same exact setup (frozen  using Pyinstaller), I am able to receive those clicks...

I don't imagine anyone has a theory, or something I should investigate or test?

See the original post in this thread for sample code and more details, and let me know if there's any other details that might help isolate the issue.


Claudia Frank

unread,
Oct 29, 2018, 9:21:43 AM10/29/18
to wxPython-users
If I understood your issue correctly then my understanding is that you need to set both,
mouse AND keyboard input to false in order to be able to receive the events in the parent control.

        #%%
        # VLC receive mouse clicks?
        self.player.video_set_mouse_input(False)
        self.player.video_set_key_input(False)

Cheers
Claudia

wrybread

unread,
Oct 29, 2018, 5:32:31 PM10/29/18
to wxPython-users
If I understood your issue correctly then my understanding is that you need to set both,
mouse AND keyboard input to false in order to be able to receive the events in the parent control.

        #%%
        # VLC receive mouse clicks?
        self.player.video_set_mouse_input(False)
        self.player.video_set_key_input(False)

Thank you so much! Works beautifully with that change.

 

wrybread

unread,
Oct 31, 2018, 5:27:17 PM10/31/18
to wxPython-users
Strange, it still doesn't work on a Windows touchscreen (a Microsoft Surface running Windows 10). The clicks are registered everywhere else, but not on the VLC panel. 

I get an indication that the click happened (a little circle), but nothing is registered by wxPython. 

Longshot I know, but does anyone happen to have an idea or a theory?

Claudia Frank

unread,
Nov 2, 2018, 9:39:52 AM11/2/18
to wxPython-users
>but does anyone happen to have an idea or a theory?

I assume a WM_TOUCH is sent and that, possibly, VLC isn't forwarding such message(event).
Maybe you wanna hook into the window message queue and see if this is really a case.
I don't have a touchscreen so aren't able to test this.

Cheers
Claudia
Reply all
Reply to author
Forward
0 new messages