Embedding VLC in a PyQt4 app

This forum is about all development around libVLC.
daimoner
New Cone
New Cone
Posts: 1
Joined: 16 Feb 2010 20:28

Embedding VLC in a PyQt4 app

Postby daimoner » 16 Feb 2010 21:07

Hello,

I'm trying to embed a VLC player in a python application based on PyQt4. Currently, I'am able to display a video using VLC Python bindings but only in a separate windows (title: VLC Direct3D output) with the following code:

Code: Select all

import sys from PyQt4 import Qt import vlc app = Qt.QApplication(sys.argv) video = Qt.QWidget() video.setMinimumSize(300, 300) path="xxx" instance=vlc.Instance() media=instance.media_new(path) player=instance.media_player_new() player.set_media(media) #Is it correct? Without these 2 lines I get a separate video display otherwise I see nothing... hwnd = video.winId().__hex__() player.set_hwnd(hwnd); player.play() video.show() app.exec_()
Any idea why this does not work?

Thanks!

ppaulojr
Blank Cone
Blank Cone
Posts: 10
Joined: 11 Feb 2010 13:48

Re: Embedding VLC in a PyQt4 app

Postby ppaulojr » 17 Feb 2010 18:06

I have the same problem.

Plus: the input in Direct 3D window is not forwarded to libvlc neither is used as hotkey

dvdjimmy
New Cone
New Cone
Posts: 2
Joined: 05 Aug 2010 11:26

Re: Embedding VLC in a PyQt4 app

Postby dvdjimmy » 05 Aug 2010 11:29

Dear all,

it seems that this is still an unsolved issue. I have exactly the same behaviour right now.

Here is the code I use

Code: Select all

import sys import sys from PyQt4 import Qt import vlc app = Qt.QApplication(sys.argv) video = Qt.QWidget() video.setMinimumSize(300, 300) path="test" instance=vlc.Instance() media = instance.media_new(path) player=instance.media_player_new() player.set_media(media) player.play() video.show() app.exec_()
An extra VLC Direct3D Output window is displayed in which the video is running. What do I have to change to display it directly in the widget?

Thank you in advance for your help.
dvdjimmy

dvdjimmy
New Cone
New Cone
Posts: 2
Joined: 05 Aug 2010 11:26

Re: Embedding VLC in a PyQt4 app

Postby dvdjimmy » 05 Aug 2010 11:54

I found a solution. The Problem is, that you have to tell VLC to which window it should render. Just add these two lines to your code and it works fine.

Code: Select all

hwnd = int(video.winId()) player.set_hwnd(hwnd)
Its very important that you convert the winId() to int. Otherwise it will not work!!

Happy coding..

dvdjimmy


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests