Coder Social home page Coder Social logo

mopidy / mopidy-mpris Goto Github PK

View Code? Open in Web Editor NEW
34.0 11.0 12.0 198 KB

Mopidy extension for controlling Mopidy through the MPRIS D-Bus interface

Home Page: https://mopidy.com/ext/mpris/

License: Apache License 2.0

Python 100.00%
python mopidy mpris mopidy-frontend

mopidy-mpris's Introduction

Mopidy-MPRIS

Latest PyPI version CI build status Test coverage

Mopidy extension for controlling Mopidy through D-Bus using the MPRIS specification.

Mopidy-MPRIS supports the minimum requirements of the MPRIS specification as well as the optional Playlists interface. The TrackList interface is currently not supported.

Maintainer wanted

Mopidy-MPRIS is currently kept on life support by the Mopidy core developers. It is in need of a more dedicated maintainer.

If you want to be the maintainer of Mopidy-MPRIS, please:

  1. Make 2-3 good pull requests improving any part of the project.

  2. Read and get familiar with all of the project's open issues.

  3. Send a pull request removing this section and adding yourself as the "Current maintainer" in the "Credits" section below. In the pull request description, please refer to the previous pull requests and state that you've familiarized yourself with the open issues.

    As a maintainer, you'll be given push access to the repo and the authority to make releases to PyPI when you see fit.

Table of contents

Requirements

  • pydbus D-Bus Python bindings, which again depends on python-gi. Thus it is usually easiest to install with your distribution's package manager.

Installation

Install by running:

sudo python3 -m pip install Mopidy-MPRIS

See https://mopidy.com/ext/mpris/ for alternative installation methods.

Configuration

No configuration is required for the MPRIS extension to work.

The following configuration values are available:

  • mpris/enabled: If the MPRIS extension should be enabled or not. Defaults to true.
  • mpris/bus_type: The type of D-Bus bus Mopidy-MPRIS should connect to. Choices include session (the default) and system.

Usage

Once Mopidy-MPRIS has been installed and your Mopidy server has been restarted, the Mopidy-MPRIS extension announces its presence on D-Bus so that any MPRIS compatible clients on your system can interact with it. Exactly how you control Mopidy through MPRIS depends on which MPRIS client you use.

Clients

The following clients have been tested with Mopidy-MPRIS.

GNOME Shell builtin

State:
Not working
Tested versions:
Ubuntu 18.10, GNOME Shell 3.30.1-2ubuntu1, Mopidy-MPRIS 2.0.0

GNOME Shell, which is the default desktop on Ubuntu 18.04 onwards, has a builtin MPRIS client. This client seems to work well with Spotify's player, but Mopidy-MPRIS does not show up here.

If you have any tips on what's missing to get this working, please open an issue.

gnome-shell-extensions-mediaplayer

State:
Working
Tested versions:
Ubuntu 18.10, GNOME Shell 3.30.1-2ubuntu1, gnome-shell-extension-mediaplayer 63, Mopidy-MPRIS 2.0.0
Website:
https://github.com/JasonLG1979/gnome-shell-extensions-mediaplayer

gnome-shell-extensions-mediaplayer is a quite feature rich MPRIS client built as an extension to GNOME Shell. With the improvements to Mopidy-MPRIS in v2.0, this extension works very well with Mopidy.

gnome-shell-extensions-mpris-indicator-button

State:
Working
Tested versions:
Ubuntu 18.10, GNOME Shell 3.30.1-2ubuntu1, gnome-shell-extensions-mpris-indicator-button 5, Mopidy-MPRIS 2.0.0
Website:
https://github.com/JasonLG1979/gnome-shell-extensions-mpris-indicator-button/

gnome-shell-extensions-mpris-indicator-button is a minimalistic version of gnome-shell-extensions-mediaplayer. It works with Mopidy-MPRIS, with the exception of the play/pause button not changing state when Mopidy starts playing.

If you have any tips on what's missing to get the play/pause button display correctly, please open an issue.

Ubuntu Sound Menu

State:
Unknown

Historically, Ubuntu Sound Menu was the primary target for Mopidy-MPRIS' development. Since Ubuntu 18.04 replaced Unity with GNOME Shell, this is no longer the case. It is currently unknown to what degree Mopidy-MPRIS works with old Ubuntu setups.

If you run an Ubuntu setup with Unity and have tested Mopidy-MPRIS, please open an issue to share your results.

Advanced setups

Running as a service

If you have input on how to best configure Mopidy-MPRIS when Mopidy is running as a service, please add a comment to issue #15.

MPRIS on the system bus

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

Few MPRIS clients will try to access MPRIS devices on the system bus, so this will give you limited functionality. For example, media keys in GNOME Shell does not work with media players that expose their MPRIS interface on the system bus instead of the user's session bus.

The default setup will often not permit Mopidy to publish its service on the D-Bus system bus, causing a warning similar to this in Mopidy's log:

MPRIS frontend setup failed (g-dbus-error-quark:
GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Connection ":1.3071"
is not allowed to own the service "org.mpris.MediaPlayer2.mopidy" due to
security policies in the configuration file (9))

To solve this, create the file /etc/dbus-1/system.d/org.mpris.MediaPlayer2.mopidy.conf with the following contents:

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <!-- Allow mopidy user to publish the Mopidy-MPRIS service -->
  <policy user="mopidy">
    <allow own="org.mpris.MediaPlayer2.mopidy"/>
  </policy>

  <!-- Allow anyone to invoke methods on the Mopidy-MPRIS service -->
  <policy context="default">
    <allow send_destination="org.mpris.MediaPlayer2.mopidy"/>
    <allow receive_sender="org.mpris.MediaPlayer2.mopidy"/>
  </policy>
</busconfig>

If you run Mopidy as another user than mopidy, you must update user="mopidy" in the above file accordingly.

Once the file is in place, you must restart Mopidy for the change to take effect.

To test the setup, you can run the following command as any user on the system to play/pause the music:

dbus-send --system --print-reply \
  --dest=org.mpris.MediaPlayer2.mopidy \
  /org/mpris/MediaPlayer2 \
  org.mpris.MediaPlayer2.Player.PlayPause

UPnP/DLNA with Rygel

Rygel is an application that will translate between Mopidy's MPRIS interface and UPnP. Rygel must be run on the same machine as Mopidy, but will make Mopidy controllable by any device on the local network that can control a UPnP/DLNA MediaRenderer.

The setup process is approximately as follows:

  1. Install Rygel.

    On Debian/Ubuntu/Raspbian:

    sudo apt install rygel
    
  2. Enable Rygel's MPRIS plugin.

    On Debian/Ubuntu/Raspbian, edit /etc/rygel.conf, find the [MPRIS] section, and change enabled=false to enabled=true.

  3. Start Rygel.

    To start it as the current user:

    systemctl --user start rygel
    

    To make Rygel start as the current user on boot:

    systemctl --user enable rygel
    
  4. Configure your system's firewall to allow the local network to reach Rygel. Exactly how is out of scope for this document.

  5. Start Mopidy with Mopidy-MPRIS enabled.

  6. If you view Rygel's log output with:

    journalctl --user -feu rygel
    

    You should see a log statement similar to:

    New plugin "org.mpris.MediaPlayer2.mopidy" available
    
  1. If everything went well, you should now be able to control Mopidy from a device on your local network that can control an UPnP/DLNA MediaRenderer, for example the Android app BubbleUPnP.

Alternatively, upmpdcli combined with Mopidy-MPD serves the same purpose as this setup.

Development tips

Mopidy-MPRIS has an extensive test suite, so the first step for all changes or additions is to add a test exercising the new code. However, making the tests pass doesn't ensure that what comes out on the D-Bus bus is correct. To introspect this through the bus, there's a couple of useful tools.

Browsing the MPRIS API with D-Feet

D-Feet is a graphical D-Bus browser. On Debian/Ubuntu systems it can be installed by running:

sudo apt install d-feet

Then run the d-feet command. In the D-Feet window, select the tab corresponding to the bus you run Mopidy-MPRIS on, usually the session bus. Then search for "MediaPlayer2" to find all available MPRIS interfaces.

To get the current value of a property, double-click it. To execute a method, double-click it, provide any required arguments, and click "Execute".

For more information on D-Feet, see the GNOME wiki.

Testing the MPRIS API with pydbus

To use the MPRIS API directly, start Mopidy, and then run the following in a Python shell to use pydbus as an MPRIS client:

>>> import pydbus
>>> bus = pydbus.SessionBus()
>>> player = bus.get('org.mpris.MediaPlayer2.mopidy', '/org/mpris/MediaPlayer2')

Now you can control Mopidy through the player object. To get properties from Mopidy, run for example:

>>> player.PlaybackStatus
'Playing'
>>> player.Metadata
{'mpris:artUrl': 'https://i.scdn.co/image/8eb49b41eeb45c1cf53e1ddfea7973d9ca257777',
 'mpris:length': 342000000,
 'mpris:trackid': '/com/mopidy/track/36',
 'xesam:album': '65/Milo',
 'xesam:albumArtist': ['Kiasmos'],
 'xesam:artist': ['Rival Consoles'],
 'xesam:discNumber': 1,
 'xesam:title': 'Arp',
 'xesam:trackNumber': 5,
 'xesam:url': 'spotify:track:7CoxEEsqo3XdvUsScRV4WD'}
>>>

To pause Mopidy's playback through D-Bus, run:

>>> player.Pause()
>>>

For details on the API, please refer to the MPRIS specification.

Project resources

Credits

mopidy-mpris's People

Contributors

jodal avatar kingosticks avatar kmiterror avatar neocturne avatar trygveaa avatar v02460 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mopidy-mpris's Issues

MPRIS does not work on Raspbian / Raspberry Pi

Clean installation of the latest version of Raspbian. Installed Mopidy with Spotify extension, working as expected.

The MPRIS extension does not work. When Mopidy is started, I get this:

MPRIS server connected to D-Bus
MPRIS frontend setup failed ('module' object has no attribute 'Server')

Any ideas?

PS: It works as expected on my Ubuntu 12.04 laptop.

Standalone client

As a user I'd like to run mopidy on a remote server and communicate with it using mpris.
It would be great to have a standalone version of mopidy-mpris, that runs on the client and connects to a mopidy-mpris-socket plugin via tcp / unix sockets.

This also would avoid patching mpris clients to use the system-wide dbus for communication with mopidy, if the mopidy server is run by another user.

Previous not working

local/mopidy 0.19.4-1
    Mopidy is a music server which can play music both from multiple
    sources, like your local hard drive, radio streams, and from Spotify
    and SoundCloud.
local/mopidy-spotify 1.2.0-1
    Mopidy extension for playing music from Spotify
local/mopidy-spotify-tunigo 0.2.1-3
    Mopidy extension for providing the browse feature of Spotify

mopidy-mpris from git

Running

qdbus-qt4 org.mpris.MediaPlayer2.mopidy /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

does nothing

Setting volume through MPRIS does not work

I noticed that setting the volume to anything below 1 (100 %) does not work:

qdbus org.mpris.MediaPlayer2.mopidy /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set org.mpris.MediaPlayer2.Player Volume 0.5

It aways set the volume to 100 % because the comparison is true for value > 1.

However, if value is parsed as a float before comparing, it works, so adding this to the top of the function fixes it:

value = float(value)

Am I doing the qdbus command wrong, or is this a bug?

Wrong types for properties

(rygel:6812): GLib-GIO-WARNING **: 19:50:19.607: Received property Position with type i does not match expected type x in the expected interface

(rygel:6812): GLib-GIO-WARNING **: 19:50:19.608: Received property Metadata with type a{ss} does not match expected type a{sv} in the expected interface

See https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:Position and https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:Metadata

seeked() got an unexpected keyword argument 'time_position'

Got this when running Mopidy-MPRIS 1.1.1 with Mopidy 1.0.4:

ERROR    Unhandled exception in MprisFrontend (urn:uuid:e5e7794c-2db7-48cb-b85d-d85fe48b96d8):
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/pykka/actor.py", line 200, in _actor_loop
    response = self._handle_receive(message)
  File "build/bdist.linux-x86_64/egg/pykka/actor.py", line 294, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/home/jodal/dev/mopidy/mopidy/core/listener.py", line 34, in on_event
    getattr(self, event)(**kwargs)
TypeError: seeked() got an unexpected keyword argument 'time_position'

"An X11 $DISPLAY is needed to use D-Bus" when running as system daemon

I am running mopidy as a system daemon in it's own separate user. I think this is a good way to run i for my purposes, but I would like to be able to control mopidy with my keyboard's media keys when I am logged in on the computer running mopidy.

I am getting this error when I try to run mopidy with mpris:

INFO     Disabled extension mpris: An X11 $DISPLAY is needed to use D-Bus

I do not know how dbus works beside being a message bus, but as far as I understand there is a system wide bus in addition to the user specific bus. I have a feeling the MPRIS media events are only broadcast on the user bus, in which case this might be impossible. Either way, I'd like to somehow control mopidy through the media keys on my keyboard.

Album art not showing up

I was using MPD and mpDris2 until today when I decided to switch to Mopidy. Previously I had album art show up on mpris clients, but not with this new combination. Is this feature not implemented or am I missing something in my setup? My album art is inside the album directory as cover.jpg.

When song updates in a streaming, the signal PropertiesChanged is not raised

Hi developers!

I'm facing with this issue. In HTTP streaming, when available, the metadata can be retrieved, however on song changes, the signal PropertiesChanged is not emitted. Only when another event is raised like pause, volume, ..., the updated metadata is showed.

In D-feet the property Metadata is updated with double click on the field. I don't know whether this is a bug or i'm missing something.

Thanks.

Plasma 5 panel crashes if playlist is empty

Not sure if this issue is with mopidy-mpris or the Plasma media player widget. When the playlist in mopidy is empty (for instance on first start or when explicitly clearing the playlist), Plasma crashes. If the playlist is not empty, everything works well.

Please tell me if I can provide any useful debugging.

Document recommendations for headless setups

  • Use case: Run Mopidy-MPRIS + Rygel on a headless system to support playing audio in Mopidy from an UPnP client.
  • Research: Does any MPRIS clients support using the system bus?
  • Research: Can we start a session bus if there's none? Ref. wrap-dbus script. Will Rygel running as some other user on the system be able to connect to Mopidy-MPRIS using the mopidy user's session bus?

No property state signal sent when PlaybackStatus goes to "Stopped"

Use case:
Stop the player using mpris stop function or the button on the mopidy http frontend.

Observed:
No property change signal sent when the PlaybackStatus property changes to "Stopped"

Expected
Signal sent

Why
Some player backends are confused if they are not getting informed about the change to stopped
-> Tested with mopidy <-(dbus)-> rygel <-(dlna)-> sony experia music app

Proposed solution
add to frontend.py:

def playback_state_changed(self, old_state, new_state):
logger.debug('Received track_playback_state_changed event: %s,%s',old_state, new_state)
if new_state == 'stopped':
self._emit_properties_changed(
objects.PLAYER_IFACE, ['PlaybackStatus'])

Just to add
I did take a look at master, lot of things seem to have changed but still it looks like the stop event from mopidy is ignored.

Empty SupportedMimeTypes array

Im trying to use mopidy-mpris plugin + rygel to make dlna renderer from mopidy.
Unfortunately SupportedMimeTypes array is always empty in my case. Thus when trying to play a file via BubbleUpnp (or any other player) I get 'MIME not supported' message.

When using upnp inspector I see empty DIDL section after invoking GetProtocolInfo command. SupportedMimeTypes array is empty when I get properties in python with

props = player.GetAll('org.mpris.MediaPlayer2', dbus_interface='org.freedesktop.DBus.Properties')

If I use playbin plugin from rygel, I can play music without any problems.

My configuration is:

  • Ubuntu 13.10 (chrooted on Samsung i9000, armhf architecture)
  • gstreamer0.10 + 1.2.0-1
  • mopidy 0.18.3 + mopidy-mpris 1.1.1
  • rygel 0.18.4

Is there some dependency I'm missing? I looked through sources, and I understand that SupportedMimeTypes array is initialized as empty. Is it not implemented yet? Or maybe I'm missing something?

Issues od KDE plasma 5

I'm running kde plasma 5.24 and I have a couple a weird issue with mopidy mpris.
I'm running mopidy as a user without any modification to mpris configuration.
The issue that I'm facing is that some buttons (namely play after i click pause and the back button) are not clickable in the media player applet. They suddenly become clickable if click a couple of time the shuffle button.
Also by I have no track images for both local media and youtube music videos.

I don't know how to gain more info about this behaviour, but I'm happy to help!

Can't connect after upgrading to Mopidy 2.0.1

Everything has been working fine, and then I upgraded to Mopidy 2.0.1 and now it won't connect. I get this error:

WARNING MPRIS frontend setup failed (org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /tmp/dbus-f2aNzfac4u: Connection refused)

Anything I can try to get this working?

gnome-shell-extension-mpris-indicator-button support

In regards to your readme which states:

gnome-shell-extensions-mpris-indicator-button is a minimalistic version of gnome-shell-extensions-mediaplayer. It works with Mopidy-MPRIS, with the exception of the play/pause button not changing state when Mopidy starts playing.

If you have any tips on what's missing to get the play/pause button display correctly, please open an issue.

I am the developer of gnome-shell-extension-mpris-indicator-button

The button changes in response to the PlaybackStatus property

If it does not change to the appropriate state that means that a org.freedesktop.DBus.Properties.PropertiesChanged signal is not emitted as it should be. Either not at all, not with the new value or not with a valid value. An invalid or absent value is interpreted as "Stopped" since an invalid or absent value is in violation of the spec and ofc no signal at all means the extension has no way of knowing that the change even happened.

Whenever a property changes a org.freedesktop.DBus.Properties.PropertiesChanged should be emitted with it's new value, unless otherwise specified by the spec.

Implement the TrackList interface

Currently Mopidy-MPRIS does not implement the MPRIS TrackList interface:

Provides access to a short list of tracks which were recently played or will be played shortly. This is intended to provide context to the currently-playing track, rather than giving complete access to the media player's playlist.

Example use cases are the list of tracks from the same album as the currently playing song or the Rhythmbox play queue.

[...]

Note that the (memory and processing) burden of implementing the TrackList interface and maintaining unique track ids for the playlist can be mitigated by only exposing a subset of the playlist when it is very long (the 20 or so tracks around the currently playing track, for example). This is a recommended practice as the tracklist interface is not designed to enable browsing through a large list of tracks, but rather to provide clients with context about the currently playing track.

Feel free to 👍 this issue if you use an MPRIS client that supports this and are interested in this feature.

Not properly attached to GObject main loop

I've seen this issue myself several times, but haven't figured it out yet. Today, it was reported on the Mopidy mailing list by @byrongibson as well:

Not a big deal, I can live without MPRIS, hardly ever use it with other media players anyway. But it's not connecting in my current setup. Any ideas what I can try to get it working?

> uname -a
Linux hp-dm1-4050us 3.2.0-56-generic #86-Ubuntu SMP Wed Oct 23 09:20:45 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

> mopidy --show-config:
...
[mpris]
enabled = true
desktop_file = /usr/share/applications/mopidy.desktop
...

> mopidy
...
WARNING  MPRIS frontend setup failed (To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(...))
...

MPRIS frontend setup failed ...

I am running mopidy on a Mint system as a service using pulseaudio and it's working fine. Early days, just experimenting, but am listening to music as I write. Alas MPRIS was failing on hte lack of a $DISPLAY variable but the README here explained that and so I changed it from the session to the system bus and restarted. Only to find a new issue:

2017-06-11 16:22:45,730 WARNING [15062:MprisFrontend-11] mopidy_mpris.frontend: MPRIS frontend setup failed (org.freedesktop.DBus.Error.AccessDenied: Connection ":1.2293" is not allowed to own the service "org.mpris.MediaPlayer2.mopidy" due to security policies in the configuration file)

Alas, that one is not covered in the README ;-). Which configuration file? Looks fixable but I admit to low skills in this area and gratitude for any pointers and perhaps the learning belongs in the README. I kind of like the MPRIS support on the HTPC I'm using.

MPRIS frontend setup failed (org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11)

Hi

" MPRIS frontend setup failed (org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11)"

I saw the message above in the log and I have no idea why that is the case. After googling abit I tried using "system" for dbus thingy then this is what I got

WARNING MPRIS frontend setup failed (org.freedesktop.DBus.Error.AccessDenied: Connection ":1.165" is not allowed to own th[54/278]
e "org.mpris.MediaPlayer2.mopidy" due to security policies in the configuration file)

Catch 22?

I am using mopid 2.1.0 on Debian Testing x64 with systemd.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.