media/vlc/ VlcHttpInterface


Enable via preferences (show all). When logging in from a browser, leave the user field blank and just enter the password. You can specify the port and password via the --http-port and --http-password arguments. For convenience, I setup a 'search engine' in Chrome so that vl hostname/port expands to http://my-pi/vlc/host/port which, in turn, is serviced by the following php:

<?php
$a = $_SERVER['REQUEST_URI'];
function vlc_redirect($host,$port) {
  $url = "http://:CorrectHorseBatteryStaple@$host:$port/";
  #echo "Redirect: $url\n";
  #exit();
  header('Location: '.$url);
  exit();
}
function get_port($a) {
  $n = intval($a);
  if( $n < 1024 ) {
    $n += 8000;
  }
  return $n;
}
function get_host($host) {
  global $hosts;
  if( array_key_exists($host,$hosts) ) {
    return $hosts[$host];
  } else {
    return $host;
  }
}
$hostre = "[a-zA-Z0-9]+";
$hosts = [ "lh" => "localhost", "t" => "randomturnip", "b" => "bumblesnarf" ]; # shorthands for common host names
if( preg_match("@^/vlc/($hostre)/(\d+)$@",$a,$m) ) {
  $host = get_host($m[1]);
  $port = get_port($m[2]);
  vlc_redirect($host,$port);
} else if( preg_match("@^/vlc/(\d+)$@",$a,$m) ) {
  $host = "localhost";
  $port = get_port($m[1]);
  #echo "$host $port";
  vlc_redirect($host,$port);
} else if(preg_match("@^/($hostre)/(\d+)$@",$a,$m)) {
  $host = get_host($m[1]);
  $port = get_port($m[2]);
  vlc_redirect($host,$port);
} else {
  echo "invalid port: use http://my-pi/\$vlc_host/\$port_no<br/>
    or http://my-pi/vlc/\$vlc_host/\$port_no\n";
  exit();
}

and the following .htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^vlc/.* vlc_host_login.php [L]