我正在使用Raspberry Pi进行主机项目。目的是在主机上具有图形用户界面,以便在播放音乐时控制电话。
我似乎无法让手机启用“随机播放”或“重复播放”。
我正在使用Bluez 5.45和GLIB。我对播放,停止,下一步有基本控制。
是否有与g_dbus_proxy_set_cached_property()类似的功能?
我已经尝试过函数g_dbus_proxy_set_cached_property(),但它仅更新缓存的值,电话从不接收该值集。
我发现了如何设置/获取属性。我使用了g_dbus_proxy_call_sync方法。
g_dbus_proxy_call_sync (GDBusProxy *proxy,
const gchar *method_name,
GVariant *parameters,
GDBusCallFlags flags,
gint timeout_msec,
GCancellable *cancellable,
GError **error);
我需要访问“ org.freedesktop.DBUS.Properties”界面。我需要使用“设置”方法。它需要三个参数。
Set(String interface_name, String property_name, A value)
value-属性的新值(可以是任何有效的DBUS类型)。
g_dbus_proxy_call_sync( myProxy,
"org.freedesktop.DBus.Properties.Set",
g_variant_new ("(ssv)",
"org.bluez.MediaPlayer1",
"Repeat",
g_variant_new_string ("alltracks")),
G_DBUS_CALL_FLAGS_NONE, // Flags
-1, // timeout
NULL, // cancellable
&error // error
);