Can't hide VLC player from callback after it reaches 'Ended' State, in python / gtk3 / windows

This forum is about all development around libVLC.
Cimbali
New Cone
New Cone
Posts: 3
Joined: 15 Feb 2016 17:38

Can't hide VLC player from callback after it reaches 'Ended' State, in python / gtk3 / windows

Postby Cimbali » 15 Feb 2016 19:28

Hello everyone.

I'm trying to get video support to work in a cross-platform PDF presentation tool written in python (called pympress). I figured VLC was a good way to go.

I manage to get a video to play within an overlay to show/hide it whenever I want. It can be resized, removed, paused, stopped, etc, mostly no problems on all platforms.

the bug
However, on windows only, I get the following:
- the VLC video output appears to be 'on top' of my Gtk widgets such that those do not receive click events anymore. I suppose this is by design (?) and is not much of a problem in itself anyway.
- The following error message: "core vout display error: Failed to set on top"
- Same good behaviour *except* once VLC is done playing. In that case, when the player reports it has the state 'ended', and as soon as the MediaPlayerEndReached callback is called, the zone where the video was played becomes 'unresponsive', that is Gtk widgets can't draw on that area anymore, it is not resizable, etc.

reproducible example
I have created a minimal example, available here: https://gist.github.com/Cimbali/86a081e78b0ffc691b50 (I usually test it with the following very short video: https://cimba.li/video.mpeg but it should be reproducible with any file)

Current behaviour:
- after the file is done playing, the last frame remains visible
- if the window is moved or another is put on top of it, this "last frame" zone is filled with garbage
- pressing stop, i.e. calling player.stop(), (while the video is playing or after the video is done playing) avoids (resp. fixes) this weird effect
- calling player.stop() from the MediaPlayerEndReached callback (in this example, the function VLCVideoDA.hide) freezes the whole program

Desired behaviour:
- after the file is done playing, the area where the video played goes back to showing what was behind it, as before it played (in this case: black), without user intervention


questions
So my questions are: what happens here? Why can't I call player.stop() within the callback? How can I achieve the desired behaviour?


references
Versions of the software I'm using are:
- Windows 7
- python 3.4.3 (64b), this was verified with python 2.7 (64b) as well
- Gtk+3 from pygobject for windows (https://sourceforge.net/projects/pygobjectwin32/) version 3.18.2
- VLC 2.2.2 (64b)
- python-vlc 1.1.2 (as distributed through pip)

Cimbali
New Cone
New Cone
Posts: 3
Joined: 15 Feb 2016 17:38

Re: Can't hide VLC player from callback after it reaches 'Ended' State, in python / gtk3 / windows

Postby Cimbali » 01 Mar 2016 17:09

Is this even the right place to ask? If not, then where?

OlivierAubert
Developer
Developer
Posts: 92
Joined: 08 Mar 2007 15:43

Re: Can't hide VLC player from callback after it reaches 'Ended' State, in python / gtk3 / windows

Postby OlivierAubert » 09 Apr 2016 00:23

The libvlc is not reentrant, especially wrt callbacks (see https://forum.videolan.org/viewtopic.php?t=80305 for instance). You should make sure the libvlc functions are called from the same thread. This can be done through signals in gtk.

Cimbali
New Cone
New Cone
Posts: 3
Joined: 15 Feb 2016 17:38

Re: Can't hide VLC player from callback after it reaches 'Ended' State, in python / gtk3 / windows

Postby Cimbali » 23 Jun 2016 18:44

Great, thanks a lot! I've updated the Gist and wrapped everything in Glib.idle_add so everything is called from the main thread, and more importantly not from within a callback.

See updated version here if that's useful for anyone, (and original version for reference)


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 19 guests