Python VLC is a library to control
vlc from python.
There is not usable online documentation, you'll have to go through the
help(<component>) inside the python console.
pip install python-vlc
You can create an instance of the
vlc player with:
import vlc player = vlc.MediaPlayer('path/to/file.mp4')
player has the next interesting methods:
play(): Opens the program and starts playing, if you've used
pauseit resumes playing.
pause(): Pauses the video
stop(): Closes the player.
set_fulscreen(1): Sets to fullscreen if you pass
0as argument it returns from fullscreen.
set_media(vlc.Media('path/to/another/file.mp4')): Change the reproduced file. It can even play pictures!
If you want more control, it's better to use an
vlc.Instance object to work with.
instance = Instance('--loop')
First you need to create a media list:
media_list = instance.media_list_new() path = "/path/to/directory" files = os.listdir(path) for file_ in files: media_list.add_media(instance.media_new(os.path.join(path,s)))
Then create the player:
media_player = instance.media_list_player_new() media_player.set_media_list(media_list)
Now you can use
Set playback mode⚑
There are the next playback modes: