c - 我如何获得 D-Bus 属性的值?

标签 c dbus

我正在尝试为基于 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 the Get 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/

相关文章:

c - 非阻塞 pasv sock 和阻塞连接(主动)套接字

java - 如何使用 dbus 和 NetworkManager 激活连接

c++ - QT-Dbus 信号/插槽?

c - dbus_connection_send_with_reply 超时

c++ - 如何使用 cmake 启用 qt dbus 编码(marshal)处理?

dbus - 如何定义d总线激活的systemd服务?

c - 头文件中没有定义的 Doxygen C 结构声明

c - 在 C 中获取两个数组差异的有效方法是什么?

ios - 如何从 Objective-C 调用 C 函数

在 C 中创建一个小结构 - 有一些错误