Christian and Alexandru have excellent points.
Being retired, I write boss-free dangerous code for my own personal pleasure. With that caveat clearly understood:
Here's a tk example. The comments show how to get the VLC settings right. If you startup a single VLC with some video, the script has 3 buttons to skip and pause. It uses localhost ip and default port built in is 8080.
VLC portable (on windows, I don't use on linux) is self contained in it's own directory tree. The config is there, not in some windows directory. That's how it's portable. (I get the win vlc portable from
portableapps.com)
I only run vlc on a fire-walled lan, and so I don't worry about hard-coding in the password, since it's not very secure anyway. Change it below in the argument {password xyz}. Leave username blank.
# vlc example http
# console show
# see this to set config
https://wiki.videolan.org/Documentation:Modules/http_intf/
# for pref's all prefs -> main interfaces -> turn on Web, and enter http as shown
# Also, under main interfaces -> Lua, under lua http enter a password, example: xyz
# The username needs to be sent in, but must be blank
#
package require http
package require base64 ;#There's a built-in command now to do this, this code is old
set playerhost 127.0.0.1
set port 8080 ;# vlc default
button .b1 -text "\u2190 3s" -command {skip -1 3} -font {TkDefaultFont 24}
button .b2 -text "\u23f8/\u25b6" -command {pause} -font {TkDefaultFont 24}
button .b3 -text "3s \u2192" -command {skip 1 3} -font {TkDefaultFont 24}
pack .b1 .b2 .b3 -fill both -expand true -side left
proc http_geturl_auth {url {username {}} {password xyz}} { ;# blank user, and password xyz
set auth "Basic [base64::encode $username:$password]"
set headerl [list Authorization $auth]
set tok [http::geturl $url -headers $headerl -timeout 200]
set result [http::data $tok]
http::cleanup $tok
# puts "result= |$result| " ;# lots of player status returned here
return $result
}
proc pause {} {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=pl_pause" ;# toggle pause/play
}
proc skip {direction secs} {
if { $direction < 0 } {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=seek&val=-${secs}s"
} else {
http_geturl_auth "http://$::playerhost:$::port/requests/status.xml?command=seek&val=%2B${secs}s"
}
}