[vlc-commits] cli: use proper binding to get current stream length

Pierre Ynard git at videolan.org
Fri Dec 2 12:11:32 CET 2016


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Fri Dec  2 12:06:50 2016 +0100| [be8f61c0a5be99d861e7d71f0b4be8f897fecc21] | committer: Pierre Ynard

cli: use proper binding to get current stream length

... instead of the "length" object variable.

Ref #17285

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=be8f61c0a5be99d861e7d71f0b4be8f897fecc21
---

 share/lua/intf/cli.lua | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/share/lua/intf/cli.lua b/share/lua/intf/cli.lua
index d848d32..6926025 100644
--- a/share/lua/intf/cli.lua
+++ b/share/lua/intf/cli.lua
@@ -430,6 +430,15 @@ function get_title(name,client)
     end
 end
 
+function get_length(name,client)
+    local item = vlc.input.item()
+    if item then
+        client:append(math.floor(item:duration()))
+    else
+        client:append("")
+    end
+end
+
 function ret_print(foo,start,stop)
     local start = start or ""
     local stop = stop or ""
@@ -590,7 +599,7 @@ commands_ordered = {
     { "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 = get_title; help = "the title of the current stream" } };
-    { "get_length"; { func = get_time("length"); help = "the length of the current stream" } };
+    { "get_length"; { func = get_length; help = "the length of the current stream" } };
     { "" };
     { "volume"; { func = volume; args = "[X]"; help = "set/get audio volume" } };
     { "volup"; { func = ret_print(vlc.volume.up,"( audio volume: "," )"); args = "[X]"; help = "raise audio volume X steps" } };



More information about the vlc-commits mailing list