====================================
Python usable definiton of MPRIS2
====================================
This is my lib to help developers work with MPRIS2 and python
See Mpris2 site (http://specifications.freedesktop.org/mpris-spec/2.2/)
See also:
========
pympris (https://github.com/wistful/pympris)
Example:
========
Here is some examples, that shows how to work with this lib.
Configure dbus and mainloop
---------------------------
>>> # configure mainloop (not required if you wont expect signals)
>>> from dbus.mainloop.glib import DBusGMainLoop
>>> DBusGMainLoop(set_as_default=True)
Discover your player mpris uri
------------------------------
>>> # you can use get_players_uri to get current running players uri
>>> from mpris2 import get_players_uri
>>> # next raise StopIteration if not found
>>> uri = next(get_players_uri())
Connect to player
-----------------
>>> # create you player
>>> from mpris2 import Player
>>> player = Player(dbus_interface_info={'dbus_uri': uri})
Call methods
------------
>>> player.Next() # play next media
Get attributes
--------------
>>> print(player.Metadata) #current media data
Wait signal
-----------
>>> def another_handler(self, *args, **kw):
>>> print(args, kw)
>>>
>>> player.PropertiesChanged = another_handler
>>> # python3
>>> import gi.repository.GLib
>>> mloop = gi.repository.GLib.MainLoop()
>>> mloop.run()
Other examples:
---------------
>>> # old versions mainloop
>>> import gobject
>>> mloop = gobject.MainLoop()
>>> # list all running players
>>> from mpris2 import get_players_uri
>>> print([uri for uri in get_players_uri()])
>>> # get_players_uri can be called with filter parameter
>>> get_players_uri('.+rhythmbox')
>>> # you can set it yourself
>>> uri = 'org.mpris.MediaPlayer2.gmusicbrowser'
>>> # or use one predefined
>>> from mpris2 import SomePlayers, Interfaces
>>> uri = '.'.join([Interfaces.MEDIA_PLAYER, SomePlayers.GMUSICBROWSER])
>>> # test other interfaces
>>> from mpris2 import MediaPlayer2
>>> mp2 = MediaPlayer2(dbus_interface_info={'dbus_uri': uri})
>>> # not all players implement this:
>>> from mpris2 import Playlists, TrackList
>>> pls = Playlists(dbus_interface_info={'dbus_uri': uri})
>>> tl = TrackList(dbus_interface_info={'dbus_uri': uri})
Raw data
{
"_id": null,
"home_page": "https://github.com/hugosenari/mpris2",
"name": "mpris2",
"maintainer": null,
"docs_url": "https://pythonhosted.org/mpris2/",
"requires_python": null,
"maintainer_email": null,
"keywords": "dbus,mpris2",
"author": "hugosenari",
"author_email": "hugosenari@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/22/b8/ce1287ef272b0fed49653a1ccb9ffea68bc5acbbc63d8027e3e18b2ca9d6/mpris2-1.0.2.tar.gz",
"platform": "UNKNOWN",
"description": "====================================\nPython usable definiton of MPRIS2\n====================================\n\nThis is my lib to help developers work with MPRIS2 and python\n\nSee Mpris2 site (http://specifications.freedesktop.org/mpris-spec/2.2/)\n\nSee also:\n========\n\npympris (https://github.com/wistful/pympris)\n\n\nExample:\n========\n\nHere is some examples, that shows how to work with this lib.\n\n\nConfigure dbus and mainloop\n---------------------------\n\n>>> # configure mainloop (not required if you wont expect signals)\n>>> from dbus.mainloop.glib import DBusGMainLoop\n>>> DBusGMainLoop(set_as_default=True)\n\n\nDiscover your player mpris uri \n------------------------------\n\n>>> # you can use get_players_uri to get current running players uri\n>>> from mpris2 import get_players_uri\n>>> # next raise StopIteration if not found\n>>> uri = next(get_players_uri())\n\n\nConnect to player\n-----------------\n\n>>> # create you player\n>>> from mpris2 import Player\n>>> player = Player(dbus_interface_info={'dbus_uri': uri})\n\n\nCall methods\n------------\n\n\n>>> player.Next() # play next media\n\n\nGet attributes\n--------------\n\n>>> print(player.Metadata) #current media data\n\n\nWait signal\n-----------\n\n\n>>> def another_handler(self, *args, **kw):\n>>> print(args, kw)\n>>> \n>>> player.PropertiesChanged = another_handler\n>>> # python3\n>>> import gi.repository.GLib\n>>> mloop = gi.repository.GLib.MainLoop()\n>>> mloop.run()\n\n\nOther examples:\n---------------\n\n>>> # old versions mainloop\n>>> import gobject\n>>> mloop = gobject.MainLoop()\n\n>>> # list all running players\n>>> from mpris2 import get_players_uri\n>>> print([uri for uri in get_players_uri()])\n>>> # get_players_uri can be called with filter parameter\n>>> get_players_uri('.+rhythmbox')\n>>> # you can set it yourself\n>>> uri = 'org.mpris.MediaPlayer2.gmusicbrowser'\n>>> # or use one predefined\n>>> from mpris2 import SomePlayers, Interfaces\n>>> uri = '.'.join([Interfaces.MEDIA_PLAYER, SomePlayers.GMUSICBROWSER])\n\n>>> # test other interfaces\n>>> from mpris2 import MediaPlayer2\n>>> mp2 = MediaPlayer2(dbus_interface_info={'dbus_uri': uri})\n>>> # not all players implement this:\n>>> from mpris2 import Playlists, TrackList\n>>> pls = Playlists(dbus_interface_info={'dbus_uri': uri})\n>>> tl = TrackList(dbus_interface_info={'dbus_uri': uri})",
"bugtrack_url": null,
"license": "GPL",
"summary": "Python mpris2 definition",
"version": "1.0.2",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/hugosenari/mpris2"
},
"split_keywords": [
"dbus",
"mpris2"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "22b8ce1287ef272b0fed49653a1ccb9ffea68bc5acbbc63d8027e3e18b2ca9d6",
"md5": "2d27fe0c15ebdbc2887c06ba55f8e0ea",
"sha256": "2663be03f07559055746ef28e6fe68792165eb3dadc84880eca8841a2a7eb185"
},
"downloads": -1,
"filename": "mpris2-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "2d27fe0c15ebdbc2887c06ba55f8e0ea",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20885,
"upload_time": "2016-05-31T05:44:31",
"upload_time_iso_8601": "2016-05-31T05:44:31.681516Z",
"url": "https://files.pythonhosted.org/packages/22/b8/ce1287ef272b0fed49653a1ccb9ffea68bc5acbbc63d8027e3e18b2ca9d6/mpris2-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2016-05-31 05:44:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hugosenari",
"github_project": "mpris2",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mpris2"
}