我正试图在Lua脚本中从DBus metadata
读取nuvolaplayer
。 (曲目)标题和专辑字段按预期显示,但艺术家数据显得奇怪:
lgi.rec 0x7f9ee8005c90:GLib.Variant Underwater Dub Dictionary
预计"Sly & Robbie"
代替"lgi.rec 0x7f9ee8005c90:GLib.Variant"
。
当我使用d-feet
查看该值时,我可以看到xesam:artist
字段与其他字段的区别在于被[] s包围。
这是我正在使用的代码:
local lgi = require 'lgi'
local Gio = lgi.require 'Gio'
local core = require 'lgi.core'
local GLib = lgi.require 'GLib'
local type,unpack = type,unpack
local bus = Gio.bus_get_sync(Gio.BusType.SESSION)
local ret,err = bus:call(
"org.mpris.MediaPlayer2.nuvolaplayer",
--"org.gnome.Rhythmbox3",
"/org/mpris/MediaPlayer2",
"org.freedesktop.DBus.Properties",
"GetAll",
GLib.Variant.new_tuple(
{
GLib.Variant("s","org.mpris.MediaPlayer2.Player")
}, 1),
nil,
Gio.DBusConnectionFlags.NONE,
-1, -- Timeout
nil, -- Cancellable
function(conn, res)
local ret, err = bus:call_finish(res)
print("here",err)
local returnValue1, returnValue2 = unpack(ret.value)
if not err then
print("META", returnValue1.Metadata["xesam:artist"],
returnValue1.Metadata["xesam:album"],
returnValue1.Metadata["xesam:title"])
end
end
)
local main_loop = GLib.MainLoop()
main_loop:run()