摘要:寻找一种使用VBA从VLC获取当前播放时间的方法
我正在寻找一种以编程方式启动VLC的方法(目前使用来自VBA / excel的shell命令)并能够以编程方式读取当前播放时间。我曾想过用LUA扩展并将当前时间写入循环中的文件。不幸的是,似乎LUA脚本不能通过命令行参数自动加载。
有没有办法做到这一点?某种VLC api?如果是这样,怎么样?
答案 0 :(得分:0)
我使用"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I http --http-host=127.0.0.1 --http-port=9090 --http-password=abc "C:\path\to\your\audio.mp3"
(请参阅https://wiki.videolan.org/VLC_HTTP_requests/)。
我启动vlc,例如使用以下命令:
Sub vlc_insert_time()
Dim req As Object
Set req = CreateObject("Microsoft.XMLHTTP")
req.Open "GET", "http://127.0.0.1:9090/requests/status.xml", False
req.SetRequestHeader "Content-Type", "application/json"
req.SetRequestHeader "Accept", "application/json"
req.SetRequestHeader "Authorization", "Basic " + EncodeBase64(StrConv("" + ":" + "abc", vbFromUnicode))
req.Send
resp = req.ResponseText
Dim obj
Set obj = CreateObject("MSXML2.DOMDocument.6.0")
obj.LoadXML (resp)
ts = o.SelectSingleNode("//root/time").text
s = "[" + Format(ts / 3600 / 24, "hh\H:mm\M:ss\S") + "]" ' adapt this to your format
Selection.TypeText s
End Sub
在Word中我使用以下VBA代码,我将其分配给快捷键(例如F8)
Base64Encode
函数Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.dataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.Text
Set objNode = Nothing
Set objXML = Nothing
End Function
来自https://stackoverflow.com/a/169945/1659599。为方便起见,我在此重复一遍:
SELECT a.*
FROM tableA a
LEFT JOIN TableB b
ON b.aid = a.id
WHERE a.status = 1 AND b.id IS NULL