【问题标题】:vlc lua: how do I get the full path of the current playing item?vlc lua:如何获取当前播放项目的完整路径?
【发布时间】:2014-09-17 22:16:11
【问题描述】:

我不是程序员,所以这对我来说很难。我想进行扩展以完整格式将完整路径发送到剪贴板。示例:

D:\MyFolder\music\audio.mp3

我最近发现并删除了this extension,它将运行时间发送到剪贴板。是否可以修改它以获取完整路径而不是运行时间?

我正在使用 VLC 媒体播放器 2.0.5 Twoflower 32 位。

Windows 7 专业版 32 位 SP1

这是我正在使用并想要修改的 .lua 文件的内容:

-- Time2Clip.lua -- VLC extension --
--[[
INSTALLATION:
Put the file in the VLC subdir /lua/extensions, by default:
* Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
Restart the VLC.
Then you simply use the extension by going to the "View" menu and selecting it.
--]]
function descriptor()
   return {
      title = "Time2Clip";
      version = "1.0";
      author = "valuex";
      url = 'https://forum.videolan.org/viewtopic.php?f=29&t=101114';
      shortdesc = "Time2Clip";
      description = "<div style=\"background-color:lightgreen;\"><b>just a simple VLC extension </b></div>";
      capabilities = {"input-listener"}
   }
end
function activate()
   create_dialog()
end

function close()
   vlc.deactivate()
end

function create_dialog()
   w = vlc.dialog("Time2Clip")
   --w2 = w:add_button("Save_to_Clip", click_SAVE,2,1,1,1)
   click_SAVE()
end

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

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

我阅读了 LUA 的 README.TXT 文件并找到了这个,但我不知道如何使用它。请帮我。提前致谢。

input.item(): Get the current input item. Input item methods are:
  :uri(): Get item's URI.
  :name(): Get item's name.

【问题讨论】:

    标签: path lua vlc


    【解决方案1】:

    怎么样:

    function descriptor()
       return {
          title = "URI2Clip";
          version = "1.0";
          author = "";
          url = '';
          shortdesc = "URI2Clip";
          description = "<div><b>Copy the media URI to the Windows clipboard</b></div>";
       }
    end
    
    function activate()
       local item = vlc.input.item()
       local uri = item:uri()
       uri = string.gsub(uri, '^file:///', '')
       uri = string.gsub(uri, '/', '\\')
    
       strCmd = 'echo '..uri..' |clip'
       os.execute(strCmd)
    end
    

    URI 返回类似file:///c:/users/username/Documents/song.mp3 的内容,因此我将其转换为c:\users\username... 格式。注意。这仅适用于保存的文件,它会破坏网址。

    【讨论】:

    • 完美运行。谢谢。我刚刚添加了这一行来更改空格字符:uri = string.gsub(uri, '%%20', ' ')
    • 您是否还需要将%20 转换为` `?
    猜你喜欢
    • 2020-10-16
    • 1970-01-01
    • 2018-08-12
    • 1970-01-01
    • 2011-03-26
    • 1970-01-01
    • 2010-10-11
    • 2011-01-28
    相关资源
    最近更新 更多