Search code examples
pythonmedia-playervlc

How can i Control VLC media player through a Python scripte


so I had this idea of controlling a media player from a python script like VLC for example, but since I am new to Python I don't know how to achieve that, so let me explain what I am looking for is for example, I want to get and set a volume value of VLC from my Python script? I am not asking for a whole code or something like that just some tips to follow and thanks in advance


Solution

  • You can use python's module vlc-ctrl for this automation. And then use subprocess module module to execute its commands.

    1) Install vlc-ctrl through pip

    pip install vlc-ctrl
    

    test.py: (To volume up)

    import subprocess
    subprocess.Popen(['vlc-ctrl',  'volume',  '+10%'])
    

    And run code with:

    python test.py
    

    More documentation for vlc-ctrl module here.