Skip to main content

VLC bindings for python.

Project description

The bindings use ctypes to directly call the libvlc dynamic lib, and the code is generated from the include files defining the public API. The same module should be compatible with various versions of libvlc 3.*. However, there may be incompatible changes between major versions.

Installing the module

You can install the module through PyPI:

pip install python-vlc

Using the module

The module offers two ways of accessing the API - a raw access to all exported methods, and more convenient wrapper classes.

Using wrapper classes

Most major structures of the libvlc API (Instance, Media, MediaPlayer, etc) are wrapped as classes, with shorter method names and some adaptations to provide a more pythonic API:

>>> import vlc
>>> player = vlc.MediaPlayer('file:///tmp/foo.avi')
>>> player.play()
>>> player.get_instance() # returns the corresponding instance

In this case, a default vlc.Instance will be instanciated and stored in vlc._default_instance. It will be used to instanciate the various classes (Media, MediaList, MediaPlayer, etc).

You also can use wrapper methods closer to the original libvlc API:

>>> import vlc
>>> instance = vlc.Instance('--no-audio', '--fullscreen')
>>> player = instance.media_player_new()
>>> player.audio_get_volume()
50
>>> media = instance.media_new('file:///tmp/foo.avi')
>>> media.get_mrl()
'file:///tmp/foo.avi'
>>> player.set_media(m)
>>> player.play()

Using raw access

Libvlc methods are available as attributes of the vlc module (as

vlc.libvlc_*). Use their docstring (any introspective shell like ipython is your friend) to explore them, or refer to the online documentation at https://olivieraubert.net/vlc/python-ctypes/

>>> import vlc
>>> vlc.libvlc_get_version()
'3.0.0-rc2 Vetinari'
>>> exc = vlc.VLCException()
>>> instance = vlc.libvlc_new(0, [], exc)
>>> instance
<vlc.Instance object at 0x8384a4c>
>>> vlc.libvlc_audio_get_volume(instance, exc)
50

Example code

You can find [example files](https://github.com/oaubert/python-vlc/tree/master/examples) in the repository.

Note that the vlc.py module can itself be invoked as an application using its own features, which also serves as a API usage example. See the [end of the module](https://github.com/oaubert/python-vlc/blob/master/generated/3.0/vlc.py#L12525) after the line if __name__ == "__main__":

License

The generated module is licensed, like libvlc, under the GNU Lesser General Public License 2.1 or later.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_vlc-3.0.21203.tar.gz (162.2 kB view details)

Uploaded Source

Built Distribution

python_vlc-3.0.21203-py3-none-any.whl (87.7 kB view details)

Uploaded Python 3

File details

Details for the file python_vlc-3.0.21203.tar.gz.

File metadata

  • Download URL: python_vlc-3.0.21203.tar.gz
  • Upload date:
  • Size: 162.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for python_vlc-3.0.21203.tar.gz
Algorithm Hash digest
SHA256 52d0544b276b11e58b6c0b748c3e0518f94f74b1b4cd328c83a59eacabead1ec
MD5 66812389afaff601a247593beb9d8d82
BLAKE2b-256 4b5bf9ce6f0c9877b6fe5eafbade55e0dcb6b2b30f1c2c95837aef40e390d63b

See more details on using hashes here.

File details

Details for the file python_vlc-3.0.21203-py3-none-any.whl.

File metadata

File hashes

Hashes for python_vlc-3.0.21203-py3-none-any.whl
Algorithm Hash digest
SHA256 1613451a31b692ec276296ceeae0c0ba82bfc2d094dabf9aceb70f58944a6320
MD5 6f2ebfde1f6d230b0480f26471bae5b5
BLAKE2b-256 5bee7d76eb3b50ccb1397621f32ede0fb4d17aa55a9aa2251bc34e6b9929fdce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page