Mopidy extension for controlling Mopidy through the MPRIS D-Bus interface
Project description
Mopidy extension for controlling Mopidy through the MPRIS D-Bus interface.
An example of an MPRIS client is the Ubuntu Sound Menu.
Dependencies
D-Bus Python bindings. The package is named python-dbus in Ubuntu/Debian.
libindicate Python bindings is needed to expose Mopidy in e.g. the Ubuntu Sound Menu. The package is named python-indicate in Ubuntu/Debian.
An .desktop file for Mopidy installed at the path set in the mpris/desktop_file config value. Mopidy installs this by default. See usage section below for details.
Installation
Debian/Ubuntu/Raspbian: Install the mopidy-mpris package from apt.mopidy.com:
sudo apt-get install mopidy-mpris
Arch Linux: Install the mopidy-mpris package from AUR:
yaourt -S mopidy-mpris
Else: Install the dependencies listed above yourself, and then install the package from PyPI:
pip install Mopidy-MPRIS
Configuration
There’s no configuration needed for the MPRIS extension to work.
The following configuration values are available:
mpris/enabled: If the MPRIS extension should be enabled or not.
mpris/desktop_file: Path to Mopidy’s .desktop file.
mpris/bus_type: The type of D-Bus bus Mopidy-MPRIS should connect to. Choices include session (the default) and system.
Usage
The extension is enabled by default if all dependencies are available.
Running as a service and connecting to the system bus
If Mopidy is running as an user without an X display, e.g. as a system service, then Mopidy-MPRIS will fail with the default config. To fix this, you can set the mpris/bus_type config value to system. This will lead to Mopidy-MPRIS making itself available on the system bus instead of the logged in user’s session bus. Note that few MPRIS clients will try to access MPRIS devices on the system bus, so this will give you limited functionality.
Testing the MPRIS API directly
To use the MPRIS API directly, start Mopidy, and then run the following in a Python shell:
import dbus bus = dbus.SessionBus() player = bus.get_object('org.mpris.MediaPlayer2.mopidy', '/org/mpris/MediaPlayer2')
Now you can control Mopidy through the player object. Examples:
To get some properties from Mopidy, run:
props = player.GetAll('org.mpris.MediaPlayer2', dbus_interface='org.freedesktop.DBus.Properties')
To quit Mopidy through D-Bus, run:
player.Quit(dbus_interface='org.mpris.MediaPlayer2')
For details on the API, please refer to the MPRIS specification.
Project resources
Changelog
v1.2.0 (2015-05-05)
Fix crash on seek event: Update seeked event handler to accept the time_position keyword argument. Recent versions of Mopidy passes all arguments to event handlers as keyword arguments, not positional arguments. (Fixes: #12)
Fix crash on tracks longer than 35 minutes: The mpris:length attribute in the Metadata property is now typed to a 64-bit integer.
Update Seek() implementation to only pass positive numbers to Mopidy, as Mopidy 1.1 is stricter about its input validation and no longer accepts seeks to negative positions.
Add a hardcoded list of MIME types to the root interface SupportedMimeTypes property. This is a temporary solution to be able to play audio through UPnP using Rygel and Mopidy-MPRIS. Long term, mopidy/mopidy#812 is the proper solution. (Fixes: #7, PR: #11)
Add a mpris/bus_type config value for making Mopidy-MPRIS connect to the D-Bus system bus instead of the session bus. (Fixes: #9, PR: #10)
Update tests to pass with Mopidy 1.0.
v1.1.1 (2014-01-22)
Fix: Make OpenUri() work even if the tracklist is empty.
v1.1.0 (2014-01-20)
Updated extension API to match Mopidy 0.18.
v1.0.1 (2013-11-20)
Update to work with Mopidy 0.16 which changed some APIs.
Remove redundant event loop setup already done by the mopidy process.
v1.0.0 (2013-10-08)
Moved extension out of the main Mopidy project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Mopidy_MPRIS-1.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a4ca4fa0b1fb207b6c2ca0dda5bbefeb2fd204a29336207f607d919af099825 |
|
MD5 | d11b082f74d39cbd4831744611820003 |
|
BLAKE2b-256 | a299f55d7bc3c7b21541db70dce25399a8b581206a1f5d3f3f5913c55efaf100 |