Help with Python Bindings

This forum is about all development around libVLC.
gsingh
New Cone
New Cone
Posts: 3
Joined: 27 Jan 2016 00:43

Help with Python Bindings

Postby gsingh » 08 Feb 2016 07:27

Hi all:

Apologize for basic question, I am new at this kind of development. I am trying to get VLc To work using python scripting.
I downloaded python 3.5.1, and the vlc.py file
how do I get started to launch vlc from python?

>>> import vlc
>>> screen1 = vlc.Instance(st)
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
screen1 = vlc.Instance(st)
NameError: name 'st' is not defined
>>> screen1 = vlc.Instance()
>>> player1=screen1.media_player_new()
>>> player1.set_media()
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
player1.set_media()
TypeError: set_media() missing 1 required positional argument: 'p_md'
>>> media1=screen1.media_new('c:\\VLCTest\Video-1028.avi')
>>> media1
<vlc.Media object at 0x0333C8B0>
>>> print media1
SyntaxError: Missing parentheses in call to 'print'
>>> print (media1)
<vlc.Media object at 0x0333C8B0>
>>> player1.set_media(media1)
>>> player1.play()
0
>>>


It does not launch a new instance of Media player, how can I force it to bring up the Media player from the python script?
ANy thing in setup I am missing?
Can anyone help? thanks

Thanks

User avatar
joba1
New Cone
New Cone
Posts: 6
Joined: 09 Mar 2016 00:42

Re: Help with Python Bindings

Postby joba1 » 14 Mar 2016 14:17

Hi,

I am also new to this stuff, but I think you misunderstand this module. It does not start the gui executable. You have to program the gui and connect a window handle of it with your player object. Look into example tkvlc.py class Player methods __init__ and OnOpen.

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

Re: Help with Python Bindings

Postby OlivierAubert » 08 Apr 2016 23:17

In fact (on windows and linux at least, macosx is different in this respect), if no video widget is specified, a new one will be created by libvlc. So the above code should work. Note that it could be shortened to

Code: Select all

import vlc p = vlc.MediaPlayer('c:\\VLCTest\Video-1028.avi') p.play()
If you do not see any output, you can enable more verbose messages to have an idea of the issue:

Code: Select all

import vlc i = vlc.Instance('--verbose 3') p = i.media_player_new() p.set_mrl('c:\\VLCTest\Video-1028.avi') p.play()

User avatar
joba1
New Cone
New Cone
Posts: 6
Joined: 09 Mar 2016 00:42

Re: Help with Python Bindings

Postby joba1 » 30 Apr 2016 15:08

oh, great, then, I guess, I can do without a working log_set() :)


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 20 guests