This project provides a Python-based interface for controlling VLC Media Player via its HTTP API. It allows you to control playback, manage volume, navigate tracks, and retrieve detailed information about the current media.
- Adjust volume within a range of 0 to 512.
- Pause or resume playback.
- Navigate to the previous or next track in the playlist.
- Fetch detailed metadata of the current media, including:
- Artist
- Title
- Album
- Artwork URL
- Playback position and duration.
- VLC Media Player with the HTTP interface enabled.
- Python 3.x.
requests
library.
-
Clone this repository:
git clone https://github.com/NullRien/VLCWebAPI.git
-
Navigate to the project directory:
cd VLCWebAPI
-
Install the required dependencies:
pip install requests
-
Enable the VLC HTTP interface:
- Enable VLC's web interface:
- Open VLC -> Tools -> Preferences -> (set show settings to all) -> Interface -> Main Interfaces.
- Check the box for "Web."
- Set a password for the VLC web interface:
- Navigate to
Main Interfaces -> Lua
. - Set a password in the "Lua HTTP" section.
- Navigate to
- Enable VLC's web interface:
-
Update the Python script with your VLC HTTP credentials.
-
Run the desired functions. For example:
from vlcapi import get_info info = get_info(password="yourpassword") print(info)
-
Set Volume:
set_volume(username="", password="yourpassword", volume=256)
-
Pause Music:
pause_music(username="", password="yourpassword")
-
Previous Track:
pl_previous(username="", password="yourpassword")
-
Next Track:
pl_next(username="", password="yourpassword")
-
Get Media Info:
get_info(username="", password="yourpassword")
All functions return a dictionary with the following structure:
{
"status": true,
"error": null,
"data": {
"volume": "256",
"current_position": "1:34",
"max_position": "4:12",
"state": "playing",
"loop": "off",
"length": "252",
"artist": "Artist Name",
"title": "Song Title",
"album": "Album Name",
"artwork_url": "file:///home/user/.cache/vlc/art/artistalbum/songname/art/art.jpg"
}
}
If people actually use this api and want more features/ease of use id gladly add them if you open a issue!