Skip to content

Python VLC

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


Basic usage

You can create an instance of the vlc player with:

import vlc

player = vlc.MediaPlayer('path/to/file.mp4')

The player has the next interesting methods:

  • play(): Opens the program and starts playing, if you've used pause it resumes playing.
  • pause(): Pauses the video
  • stop(): Closes the player.
  • set_fulscreen(1): Sets to fullscreen if you pass 0 as 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.

Configure the instance

instance = Instance('--loop')

Reproduce many files

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:

Then create the player:

media_player = instance.media_list_player_new()

Now you can use and player.previous().

Set playback mode


There are the next playback modes:

  • default
  • loop
  • repeat