⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.lua

📁 VLC Player Source Code
💻 LUA
字号:
--[[ This code is public domain (since it really isn't very interesting) ]]--module("common",package.seeall)-- Iterate over a table in the keys' alphabetical orderfunction pairs_sorted(t)    local s = {}    for k,_ in pairs(t) do table.insert(s,k) end    table.sort(s)    local i = 0    return function () i = i + 1; return s[i], t[s[i]] endend-- Return a function such as skip(foo)(a,b,c) = foo(b,c)function skip(foo)    return function(discard,...) return foo(...) endend-- Return a function such as setarg(foo,a)(b,c) = foo(a,b,c)function setarg(foo,a)    return function(...) return foo(a,...) endend-- Trigger a hotkeyfunction hotkey(arg)    vlc.var.set( vlc.object.libvlc(), "key-pressed", vlc.config.get( arg ) )end-- Take a video snapshotfunction snapshot()    local vout = vlc.object.find(nil,"vout","anywhere")    if not vout then return end    vlc.var.set(vout,"video-snapshot",nil)end-- Naive (non recursive) table copyfunction table_copy(t)    c = {}    for i,v in pairs(t) do c[i]=v end    return cend-- strip leading and trailing spacesfunction strip(str)    return string.gsub(str, "^%s*(.-)%s*$", "%1")end-- print a table (recursively)function table_print(t,prefix)    local prefix = prefix or ""    for a,b in pairs_sorted(t) do        print(prefix..tostring(a),b)        if type(b)==type({}) then            table_print(b,prefix.."\t")        end    endend-- print the list of callbacks registered in lua-- usefull for debug purposesfunction print_callbacks()    print "callbacks:"    table_print(vlc.callbacks)end -- convert a duration (in seconds) to a stringfunction durationtostring(duration)    return string.format("%02d:%02d:%02d",                         math.floor(duration/3600),                         math.floor(duration/60)%60,                         math.floor(duration%60))end-- realpathfunction realpath(path)    return string.gsub(string.gsub(string.gsub(string.gsub(path,"/%.%./[^/]+","/"),"/[^/]+/%.%./","/"),"/%./","/"),"//","/")end-- seekfunction seek(value)    local input = vlc.object.input()    if string.sub(value,#value)=="%" then        vlc.var.set(input,"position",tonumber(string.sub(value,1,#value-1))/100.)    else        vlc.var.set(input,"time",tonumber(value))    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -