I'm running on

Raspberry Pi 4 B
Python 3.11.2
python-vlc 3.0.20123

The video opens in the left corner of the screen without the frames of a window, but not in fullscreen. I'm not using any GUI library like PyQT5, just the native vlc player.

I initialize the player like so:

MEDIA_PLAYER = vlc.MediaPlayer()

How can this be fixed? I've used hours on this, trying many different solutions, but without any luck. Then again, I didn't find a post matching this behaviour, so no wonder the solutions didn't work.

1

There are 1 best solutions below

2
Lupilum On

The solution I found is to create an instance of libvlc with the flag --no-xlib, as follows:

instance = vlc.Instance("--no-xlib")
MEDIA_PLAYER = instance.media_player_new()

I'm not sure why this works. I got the idea from an example of the usage of python-vlc for gtk: https://git.videolan.org/?p=vlc/bindings/python.git;a=blob;f=examples/gtkvlc.py;h=bafb442fd76db1584e1e933c7191399fa40937e8;hb=HEAD

The relevant lines are

48 # Create a single vlc.Instance() to be shared by (possible) multiple players.
49 if 'linux' in sys.platform:
50     # Inform libvlc that Xlib is not initialized for threads
51     instance = vlc.Instance("--no-xlib")
52 else:
53     instance = vlc.Instance()