go-vlc-ctrl : Control VLC with Go
A simple yet powerful module that allows you to control VLC instances over the VLC Web API.
Installation
Make sure you have Go installed and just open up a terminal window and run:
go get github.com/CedArctic/go-vlc-ctrl
Example
To run this example, enable the VLC Web Interface (View > Add Interface > Web) and make sure it has a password set to "password" (Preferences > All > Main interfaces > Lua > Lua HTTP > Password).
Alternatively you can launch VLC with a Web Interface from the command prompt / terminal (use macosx instead of qt if on macOS):
vlc --intf http --extraintf qt --http-password password
package main
import (
"github.com/CedArctic/go-vlc-ctrl"
"time"
)
func main(){
// Declare a local VLC instance on port 8080 with password "password"
myVLC, _ := vlcctrl.NewVLC("127.0.0.1", 8080, "password")
// Add items to playlist. Note URIs are URL percent-encoded
// Warning: YouTube URLs have a = that needs to be changed to %3D (percent-encoding)
myVLC.Add("file:///C:/Users/Jose/Music/Back%%20In%%20Black.mp3")
myVLC.Add("https://www.youtube.com/watch?v%3DdQw4w9WgXcQ")
// Play first item and wait for 10 seconds
myVLC.Play()
time.Sleep(10 * time.Second)
// Skip to next item, toggle full screen and pause after 30s
myVLC.Next()
myVLC.ToggleFullscreen()
time.Sleep(30 * time.Second)
myVLC.Pause()
}
Documentation
You can find documentation of all functions on GoDoc or Go.dev.
The module fully covers the VLC Web API as documented here.
Contributing
Contributions to the project in any way are welcome
Resources
- https://wiki.videolan.org/Interfaces/
- https://wiki.videolan.org/VLC_HTTP_requests/
- https://wiki.videolan.org/Documentation:Modules/http_intf/
- https://github.com/videolan/vlc/blob/master/share/lua/http/requests/README.txt
License
Copyright (c) 2020 CedArctic. This project is licensed under the MIT license.