Skip to content

Instantly share code, notes, and snippets.

@imorrish
Created December 3, 2016 18:04
Show Gist options
  • Select an option

  • Save imorrish/5a8028f2b078c0618c4706a9ee6ab1e9 to your computer and use it in GitHub Desktop.

Select an option

Save imorrish/5a8028f2b078c0618c4706a9ee6ab1e9 to your computer and use it in GitHub Desktop.
Remote control VLC from Windows PowerShell
# Remote commands for VLC
#Run from ISE
$socket = new-object System.Net.Sockets.TcpClient("localhost", 5000)
if($socket -eq $null) {
write-host "Failed to connect to VLC"
Exit
}
$stream = $socket.GetStream()
$writer = new-object System.IO.StreamWriter($stream)
$buffer = new-object System.Byte[] 1024
$encoding = new-object System.Text.AsciiEncoding
function WriteCommand($strCommand){
## send command to VLC
write-host $strCommand
$writer.WriteLine($strCommand)
$writer.Flush()
Start-Sleep -m 500
while($stream.DataAvailable) {
$read = $stream.Read($buffer, 0, 1024)
write-host -n ($encoding.GetString($buffer, 0, $read))
}
}
do {$strResponse = Read-Host "Shorcuts = p - play, s - stop, 1-10 clip, T - time, j - Jump 10 sec, Q when you want to quit application?"
switch ($strResponse)
{
"s" {WriteCommand('stop')}
"p" {WriteCommand('play')}
"+" {WriteCommand('faster')}
"-" {WriteCommand('slower')}
"n" {WriteCommand('normal')}
"j" {WriteCommand('seek 10')}
"seek" {WriteCommand('seek 500')}
"t" {WriteCommand('get_time')}
"fon" {WriteCommand('f on')}
"foff" {WriteCommand('f off')}
"pause" {WriteCommand('pause')}
"rewind" {WriteCommand('rewind')}
"fast" {WriteCommand('fastforward')}
default {WriteCommand($_)}
}
}
until ($strResponse -eq "q")
 
#clean up
$writer.Close()
$stream.Close()
@imorrish

Copy link
Copy Markdown
Author

More info for automating things for broadcast TV or live streming at https://ianmorrish.wordpress.com

@countrycrossinglive

Copy link
Copy Markdown

this does not work on vlc 3.0.18. It does not produce any errors. The commands do not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment