I have already checked this link: How to handle properties of a dbus interface with python. However, that only lists an API... but I don't know where that API comes from.

我已经检查了这个链接:如何使用python处理dbus接口的属性。但是,它只列出一个API……但是我不知道这个API来自哪里。

I just started working with dbus (pretty excited about this, to be honest ^__^ just not too happy with the documentation I've found) on python and I was wondering if I could just get some sample code.

我刚开始使用dbus(很兴奋,老实说^ __ ^不太满意的文档我发现)在python和我想知道如果我能得到一些示例代码。

I'm using MPRIS specifically for Rhythmbox, although it 'should' be the same for all.

我使用MPRIS专门用于Rhythmbox,尽管它对所有人都是一样的。

I know I can access and have fun witht he methods by doing the following:

我知道我可以通过以下方法获得乐趣:

import dbus
bus = dbus.SessionBus()
proxy = bus.get_object('org.mpris.MediaPlayer2.rhythmbox','/org/mpris/MediaPlayer2')
player = dbus.Interface(proxy, 'org.mpris.MediaPlayer2.Player')
playlists = dbus.Interface(proxy, 'org.mpris.MediaPlayer2.Playlists')
tracklist = dbus.Interface(proxy, 'org.mpris.MediaPlayer2.TrackList')

However, I wish to know about properties. Some sample code will suffice :) Thanks!

但是,我想了解一下属性。一些示例代码就足够了:)谢谢!

1 个解决方案

#1


18

Found how.

如何找到。

proxy = bus.get_object('org.mpris.MediaPlayer2.rhythmbox','/org/mpris/MediaPlayer2')
properties_manager = dbus.Interface(proxy, 'org.freedesktop.DBus.Properties')
properties_manager.Set('org.mpris.MediaPlayer2.Player', 'Volume', 100.0)
curr_volume = properties_manager.Get('org.mpris.MediaPlayer2.Player', 'Volume')

Pretty simple indeed :) I thought it would be simple like this.

非常简单:)我想应该是这样的。

更多相关文章

  1. 获取错误“ValueError:int()的无效文字,基数为10:'3128;'在运行Tensor
  2. Python中类的使用(5私有属性)
  3. 'module'对象没有属性'views' django错误
  4. python的接口实现zope.interface示例
  5. AttributeError:“MatrixFactorizationModel”对象没有属性“sav
  6. Python------类的结构细分,异常处理,方法,属性
  7. Python进阶----类的结构(公有成员 , 私有成员(私有属性,私有方法
  8. AttributeError:'Flask'对象没有属性'login_manager' - Login_Ma
  9. 关于Python的属性、参数、方法的解释、区别

随机推荐

  1. [Innost]Android深入浅出之Binder机制
  2. json解析查找指定数据字段
  3. android 微博客户端源码
  4. android 调用call
  5. Android Studio 使用Gradle在Terminal终
  6. Android -- Dialog动画
  7. Android(安卓)Path里FillType功能
  8. Android延时任务方法
  9. android Intent打开各种类型文件((PDF、wo
  10. Androi:ViewPager