VLC time2clip.lua,拷贝当前时间戳到剪贴板的扩展格式不正确

扩展Time2Clip.lua 已经在我的桌面系统上完美运行了多年,但是我的电脑几天前崩溃了,我一直试图在我的笔记本电脑上让它工作,但是没有成功。Time2Clip.lua 和 time_ext.lua 扩展一直无法正确工作于新版本的VLC,现在两个都不工作,但是没有我的桌面系统的访问权限,我不知道我使用的VLC版本是哪一个。我一直在翻阅过去的VLC版本,希望这是问题的原因,但是到目前为止没有任何效果。我也不确定我是否有正确的lua代码,我也不了解足够的语言知识来编辑它。

Time2Clip.lua 应该返回一个像1:23:45这样的时间码,而不是返回5,025,489,999(实际上这就是1小时23分钟45秒返回的数值。微秒?Excel似乎无法将其转换回时: 分: 秒)[扩展的图片][1]

这是扩展的代码:

--[[
安装:
将文件放入VLC子目录 /lua/extensions,默认情况下为:
 Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\ 
重启VLC后,您只需转到“视图”菜单并选择它即可使用扩展。
--]]

function descriptor()
    return {
        title = "Time2Clip";
        version = "1.0";
        author = "valuex";
        url = 'http://addons.videolan.org/content/show.php?content=149618';
        shortdesc = "Time2Clip";
        description = "<div style=\"background-color:lightgreen;\"><b>只是一个简单的VLC扩展程序 </b></div>";
        capabilities = {"input-listener"}
    }
end
function activate()
    input_callback("add")
    create_dialog()
end
function deactivate()
    input_callback("del")
end
function close()
    vlc.deactivate()
end
function input_changed()
    input_callback("toggle")
end

callback=false
function input_callback(action)  -- action=add/del/toggle
    if (action=="toggle" and callback==false) then action="add"
    elseif (action=="toggle" and callback==true) then action="del" end

    local input = vlc.object.input()
    if input and callback==false and action=="add" then
        callback=true
        vlc.var.add_callback(input, "intf-event", input_events_handler, "Hello world!")
    elseif input and callback==true and action=="del" then
        callback=false
        vlc.var.del_callback(input, "intf-event", input_events_handler, "Hello world!")
    end
end

function input_events_handler(var, old, new, data)

end

function create_dialog()
    w = vlc.dialog("Time2Clip")
    w1 = w:add_label("<b>当前时间:</b>",1,1,1,1)
    w2 = w:add_text_input("0",2,1,1,1)
    w3 = w:add_button("jumpto", click_SEEK,1,2,1,1)
    w4 = w:add_button("保存到剪贴板", click_SAVE,2,2,1,1)
end

function click_SAVE()
    local input = vlc.object.input()
    if input then
        local curtime=vlc.var.get(input, "time")
        w2:set_text( curtime )
        save_to_clipboard(curtime)
    end
end

function click_SEEK()
    local time_togo = w2:get_text()
    local input = vlc.object.input()
    if input then
        vlc.var.set(input, "time", time_togo)   --跳转到指定时间
    end
end

function save_to_clipboard(var)
    strCmd = 'echo '..var..' |clip'
    os.execute(strCmd)
end

  [1]: https://i.stack.imgur.com/va4aO.png
点赞