我正在尝试为基于 MPRIS 的媒体播放器创建一个通用的远程控制应用程序。控制媒体播放器非常简单,但由于我对 D-Bus 和 DBus-GLib 很陌生,所以从 D-Bus 获取值对我来说有点搞砸了。
从文档中我看到,如果我想知道我的播放器是否真的在播放某些内容,我需要获取 PlaybackStatus 属性,但我找不到在 C 中获取此值的工作示例。
目前获取它的行如下所示:
dbus_g_proxy_call(player_proxy, "Get", &err, G_TYPE_STRING, "Volume", G_TYPE_INVALID, G_TYPE_INT, &volume, G_TYPE_INVALID);
当然,它不起作用,因为 org.mpris.MediaPlayer2.Player
接口(interface)不理解 Get 方法。
最佳答案
Certainly, it does not work, as the
org.mpris.MediaPlayer2.Player
interface doesn't understand theGet
method.
这是您需要的线索。 Get
方法实际上在 org.freedesktop.DBus.Properties
interface 上,因此您需要在该接口(interface)的代理对象上调用它,而不是 player_proxy
对象(这可能是 org.mpris.MediaPlayer2.Player
接口(interface)的代理).
关于c - 我如何获得 D-Bus 属性的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10568426/