Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Start multiple instances of mpdris #89

Closed
Fuco1 opened this issue May 13, 2017 · 10 comments
Closed

[question] Start multiple instances of mpdris #89

Fuco1 opened this issue May 13, 2017 · 10 comments

Comments

@Fuco1
Copy link

Fuco1 commented May 13, 2017

I currently use two mpd servers, one locally and one on a raspberry pi. I would like to be able to start two mpdris instances to control one or the other. Right now the older instance is replaced when I start another one.

grawity added a commit that referenced this issue May 13, 2017
For #89 and perhaps future testing. Note that this doesn't properly
implement MPRIS' multi-instance layout; instead you get two completely
independent players.
@grawity
Copy link
Collaborator

grawity commented May 13, 2017

This should now work in git – specify a custom service name for the 2nd instance, e.g.

[Connection]
host = …
bus_name = org.mpris.MediaPlayer2.mpd-rpi

(There is also a --bus-name= option. The bus name must be org.mpris.MediaPlayer2.<something>.)

@Fuco1
Copy link
Author

Fuco1 commented May 13, 2017

Damn @grawity that was fast! I'm not sure I follow with the config though. I'm not using systemd at this computer (it's an oldish linux mint ditro)

I have this in ~/.config/mpDris2/mpDris2.conf

[Connection]
host = localhost
port = 6600
password =
music_dir = /home/matus/media/music

[Connection]
host = 192.168.10.20
port = 6600
password =
bus_name=org.mpris.MediaPlayer2.mpd-rpi

[Bling]
mmkeys = False
notify = False

Is this how I should configure multiple connections?

@Fuco1
Copy link
Author

Fuco1 commented May 13, 2017

Nevermind, I botched the installation. I see 0.7 now has the -c option.

So I split the config into two, when I run the second instance I get this

[23:02:10]matus@herakleitos:/usr/local/stow
> mpDris2 -c ~/.config/mpDris2/rpi.conf
Traceback (most recent call last):
  File "/usr/local/bin/mpDris2", line 1275, in <module>
    config.read_file(fh)
AttributeError: SafeConfigParser instance has no attribute 'read_file'

grawity added a commit that referenced this issue May 13, 2017
Apparently older Python versions don't have read_file() yet.  I kept the
`with…` block though; we still want to abort if the file is missing, and
it's a cheap way to do so.

Ref #89
@grawity
Copy link
Collaborator

grawity commented May 13, 2017

What version of Python are you using? I think I'll soon declare 2.x as no longer supported...

And yes, you need one config file per instance.

@Fuco1
Copy link
Author

Fuco1 commented May 14, 2017

I use 2.7.6. I use the system installation and have mpdris also installed system-wise. I'm not too much of a python person but I know how to use virtualenv in a basic way, would that help me somehow to run this with newer version of python?

@Fuco1
Copy link
Author

Fuco1 commented May 14, 2017

Or... I guess I'll just put this into Docker :) I love putting things in Docker :D Would you be interested in having a docker version set up?

@azrdev
Copy link

azrdev commented May 14, 2017

@grawity currently (on commit 5362867), when bus name is neither given on command line nor in a config file (e.g. when no conf file exists), mdpris crashes because the variable is initialized to None:

Traceback (most recent call last):
  File "/usr/bin/mpDris2", line 1350, in <module>
    mpd_wrapper.run()
  File "/usr/bin/mpDris2", line 289, in run
    if self.my_connect():
  File "/usr/bin/mpDris2", line 336, in my_connect
    self._dbus_service = MPRISInterface(self._params)
  File "/usr/bin/mpDris2", line 873, in __init__
    if not self._name.startswith("org.mpris.MediaPlayer2."):
AttributeError: 'NoneType' object has no attribute 'startswith'

@azrdev
Copy link

azrdev commented May 14, 2017

Anyways, I can run multiple instances of mpdris in parallel with this systemd-user-unit:

[Unit]
Description=mpDris2 - Music Player Daemon D-Bus bridge (host %I)

[Service]
ExecStart=/usr/bin/mpDris2 --bus-name org.mpris.MediaPlayer2.mpd-%i  %i
BusName=org.mpris.MediaPlayer2.mpd-%i

[Install]
WantedBy=default.target

No configuration file needed.

grawity added a commit that referenced this issue May 14, 2017
I forgot that this is always /present/, so get() won't handle it.

Ref #89
@grawity
Copy link
Collaborator

grawity commented May 14, 2017

Fixed the crash. Most distributions have separate packages for Python 2.x series and 3.x series; the 3.x mpd module might be called "python-mpd2".

@Fuco1
Copy link
Author

Fuco1 commented May 16, 2017

This works for me so I think we can close? Thank you very much for implementing this.

@grawity grawity closed this as completed May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants