MPRIS + Python (dbus):读写属性
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.
非常简单:)我想应该是这样的。
更多相关文章
- 获取错误“ValueError:int()的无效文字,基数为10:'3128;'在运行Tensor
- Python中类的使用(5私有属性)
- 'module'对象没有属性'views' django错误
- python的接口实现zope.interface示例
- AttributeError:“MatrixFactorizationModel”对象没有属性“sav
- Python------类的结构细分,异常处理,方法,属性
- Python进阶----类的结构(公有成员 , 私有成员(私有属性,私有方法
- AttributeError:'Flask'对象没有属性'login_manager' - Login_Ma
- 关于Python的属性、参数、方法的解释、区别