setarg = common.setarg
strip = common.strip
+_ = vlc.gettext._
+N_ = vlc.gettext.N_
+
--[[ Setup default environement ]]
env = { prompt = "> ";
width = 70;
autocompletion = 1;
autoalias = 1;
- welcome = "Remote control interface initialized. Type `help' for help.";
+ welcome = _("Remote control interface initialized. Type `help' for help.");
flatplaylist = 0;
}
end
function add(name,client,arg)
- -- TODO: par single and double quotes properly
+ -- TODO: parse single and double quotes properly
local f
if name == "enqueue" then
f = vlc.playlist.enqueue
end
function input_info(name,client)
- local categories = vlc.input.info()
+ local item = vlc.input.item()
+ if(item == nil) then return end
+ local categories = item:info()
for cat, infos in pairs(categories) do
client:append("+----[ "..cat.." ]")
client:append("|")
end
function stats(name,client)
- local stats_tab = vlc.input.stats()
+ local item = vlc.input.item()
+ if(item == nil) then return end
+ local stats_tab = item:stats()
client:append("+----[ begin of statistical info")
client:append("+-[Incoming]")
- client:append("| input bytes read : "..string.format("%8.0f kB",stats_tab["read_bytes"]/1000))
- client:append("| input bitrate : "..string.format("%6.0f bB/s",stats_tab["input_bitrate"]*8000))
- client:append("| demux bytes read : "..string.format("%8.0f kB",stats_tab["demux_read_bytes"]/1000))
- client:append("| demux bitrate : "..string.format("%6.0f kB/s",stats_tab["demux_bitrate"]*8000))
+ client:append("| input bytes read : "..string.format("%8.0f KiB",stats_tab["read_bytes"]/1024))
+ client:append("| input bitrate : "..string.format("%6.0f kb/s",stats_tab["input_bitrate"]*8000))
+ client:append("| demux bytes read : "..string.format("%8.0f KiB",stats_tab["demux_read_bytes"]/1024))
+ client:append("| demux bitrate : "..string.format("%6.0f kb/s",stats_tab["demux_bitrate"]*8000))
client:append("| demux corrupted : "..string.format("%5i",stats_tab["demux_corrupted"]))
client:append("| discontinuities : "..string.format("%5i",stats_tab["demux_discontinuity"]))
client:append("|")
client:append("|")
client:append("+-[Streaming]")
client:append("| packets sent : "..string.format("%5i",stats_tab["sent_packets"]))
- client:append("| bytes sent : "..string.format("%8.0f kB",stats_tab["sent_bytes"]/1000))
+ client:append("| bytes sent : "..string.format("%8.0f KiB",stats_tab["sent_bytes"]/1024))
client:append("| sending bitrate : "..string.format("%6.0f kb/s",stats_tab["send_bitrate"]*8000))
client:append("+----[ end of statistical info ]")
end
function playlist_status(name,client)
- client:append( "( new input: " .. "FIXME" .. " )" )
+ local item = vlc.input.item()
+ if(item ~= nil) then
+ client:append( "( new input: " .. vlc.strings.decode_uri(item:uri()) .. " )" )
+ end
client:append( "( audio volume: " .. tostring(vlc.volume.get()) .. " )")
client:append( "( state " .. vlc.playlist.status() .. " )")
end
if vlc.input.is_playing() then client:append "1" else client:append "0" end
end
+function get_title(name,client)
+ local item = vlc.input.item()
+ if item then
+ client:append(item:name())
+ else
+ client:append("")
+ end
+end
+
function ret_print(foo,start,stop)
local start = start or ""
local stop = stop or ""
{ "chapter_p"; { func = titlechap_offset(-1); help = "previous chapter in current item" } };
{ "" };
{ "seek"; { func = seek; args = "X"; help = "seek in seconds, for instance `seek 12'" } };
- { "pause"; { func = setarg(common.hotkey,"key-play-pause"); help = "toggle pause" } };
+ { "pause"; { func = skip2(vlc.playlist.pause); help = "toggle pause" } };
{ "fastforward"; { func = setarg(common.hotkey,"key-jump+extrashort"); help = "set to maximum rate" } };
{ "rewind"; { func = setarg(common.hotkey,"key-jump-extrashort"); help = "set to minimum rate" } };
{ "faster"; { func = rate; help = "faster playing of stream" } };
{ "stats"; { func = stats; help = "show statistical information" } };
{ "get_time"; { func = get_time("time"); help = "seconds elapsed since stream's beginning" } };
{ "is_playing"; { func = is_playing; help = "1 if a stream plays, 0 otherwise" } };
- { "get_title"; { func = ret_print(vlc.input.get_title); help = "the title of the current stream" } };
+ { "get_title"; { func = get_title; help = "the title of the current stream" } };
{ "get_length"; { func = get_time("length"); help = "the length of the current stream" } };
{ "" };
{ "volume"; { func = volume; args = "[X]"; help = "set/get audio volume" } };
--[[ The main loop ]]
while not vlc.misc.should_die() do
- h:accept()
- local write, read = h:select(0.1)
+ local write, read = h:accept_and_select()
for _, client in pairs(write) do
local len = client:send()