I tried litarely every code I found on the internet to start a python-vlc player instance in a window frame made with PyQt but it's no working. The vlc player starts in a new window instead of taking the one provided py PyQt.
Can someone reproduce my problem or even solve it? I'm on Ubuntu 22.04.4 LTS using Gnome and Wayland.
Minimal example:
import sys
import vlc
from PyQt6.QtWidgets import QMainWindow, QWidget, QApplication, QVBoxLayout, QFrame
from PyQt6.QtCore import Qt
class MediaPlayer(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Media Player")
self.initUI()
def initUI(self):
self.instance = vlc.Instance("--no-xlib")
self.media = "path/to/video" # Replace with your actual video file path
self.mediaplayer = self.instance.media_player_new(self.media)
self.mediaplayer.play()
self.centralWidget = QWidget(self)
self.setCentralWidget(self.centralWidget)
layout = QVBoxLayout(self.centralWidget)
self.videoFrame = QFrame()
layout.addWidget(self.videoFrame)
self.mediaplayer.set_xwindow(int(self.videoFrame.winId()))
self.resize(640, 480)
def main():
app = QApplication(sys.argv)
player = MediaPlayer()
player.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()
Producing this error:
[00007c72c40b27a0] xcb_window window error: bad X11 window 0x00000003
[00007c72c40d2530] vdpau_avcodec generic error: Xlib is required for VDPAU
[00007c72c40b27a0] xcb_window window error: X server failure
I tried the also the following examples, non of them is working for me:
egl_x11 gl error: Xlib not initialized for threads, xcb_window window error: X server failure
vlc/mediaplayer
stuff to a separate method, and then use a single-shot timer to call it after a short delay.