Spotifyd / spotifyd

A spotify daemon
https://spotifyd.rs
GNU General Public License v3.0
9.78k stars 447 forks source link

Mpris not working? #1221

Open Arbee4ever opened 1 year ago

Arbee4ever commented 1 year ago

Description When I start spotifyd, it looks like mpris is not working, as I can't control the playback using my "Music PLayer" Extension or playerctl.

To Reproduce

  1. Start spotifyd
  2. play music
  3. try controling it with playerctl

Expected behavior Playerctl and the extension should be able to control it.

Logs

Click to show logs ``` Loading config from "/home/arbee/.config/spotifyd/spotifyd.conf" CliConfig { config_path: None, no_daemon: true, verbose: true, pid: None, shared_config: SharedConfigValues { username: Some("taken out for privacy"), username_cmd: None, password: Some("taken out for privacy"), password_cmd: None, use_keyring: false, use_mpris: None, dbus_type: None, on_song_change_hook: None, cache_path: None, no-audio-cache: false, backend: None, volume_controller: Some(Alsa), device: None, control: None, mixer: None, device_name: Some("spotifyd"), bitrate: None, audio_format: None, initial_volume: None, volume_normalisation: false, normalisation_pregain: None, zeroconf_port: None, proxy: None, device_type: Some(Computer), autoplay: false, max_cache_size: None } } Found user shell: Some("/bin/bash") No proxy specified registering event source with poller: token=Token(2147483649), interests=READABLE Using alsa volume controller. registering event source with poller: token=Token(0), interests=READABLE | WRITABLE signal: Want signal found waiting giver, notifying poll_want: taker wants! signal: Want signal: Want Ignoring blacklisted access point ap-gew4.spotify.com:4070 Ignoring blacklisted access point ap-gew4.spotify.com:443 deregistering event source from poller Ignoring blacklisted access point ap-gew4.spotify.com:80 Ignoring blacklisted access point ap-gue1.spotify.com:4070 Connecting to AP "ap-gae2.spotify.com:443" signal: Closed registering event source with poller: token=Token(16777216), interests=READABLE | WRITABLE Authenticated as "1doctorproctor1" ! new Session[0] Session[0] strong=3 weak=1 Country: "DE" new Spirc[0] canonical_username: 1doctorproctor1 new MercuryManager new Player[0] Converting with ditherer: tpdf Using AlsaSink with format: S16 command=AddEventSender command=VolumeSet(0) subscribed uri=hm://remote/user/1doctorproctor1/ count=0 kMessageTypeNotify "Pixel 6" 07d93ca34490b752c30032f3eaf210a6424d4942 1558149747 1693775263583 kPlayStatusStop kMessageTypeNotify "Pixel 6" 07d93ca34490b752c30032f3eaf210a6424d4942 1558164304 1693775278140 kPlayStatusPlay kMessageTypeNotify "Pixel 6" 07d93ca34490b752c30032f3eaf210a6424d4942 1558169700 1693775283536 kPlayStatusPlay kMessageTypeLoad "Pixel 6" 07d93ca34490b752c30032f3eaf210a6424d4942 1558170646 1693775283536 kPlayStatusPlay State: context_uri: "spotify:playlist:3rKLlnjjjcNhDmQKS5qdHH" index: 0 position_ms: 19098 status: kPlayStatusPlay position_measured_at: 1693775284525 context_description: "" shuffle: true repeat: true playing_from_fallback: true row: 0 playing_track_index: 0 track {gid: "\360\334\355.r\232N\311\270k\336\304\0003\"a"} track {gid: "\005n\033\222K?C\023\230\266\243\312\300J\275\240"} track {gid: "U\272\224*\254\257J\331\245\275\270\366p\3511Q"} track {gid: "\363n\n\344\022\222I\272\250[\303\017H\351\021T"} track {gid: "\277\301\035K\010\240G:\242D\010\310\245\332+\253"} track {gid: "R\016\234\237\341\003Mk\231\\Ef\2320c\365"} track {gid: "u\213\345(\3042K8\245Xc\242q\337\367\352"} track {gid: "0\201R\202\025\343D\203\256]\307\322\r\325\207C"} track {gid: "h%\232\235J\234O\222\243X\263f\314yo\336"} track {gid: "p\025\323\261\007]F\373\277G\375\2454r\370;"} track {gid: "\201V\364\376\216\020B2\252\021\230\360\261\213O\356"} track {gid: "\316M\214\234\333&J\026\253\227\003\0216\257\263\027"} track {gid: "\263P\330vc\300Mf\251a\006\271(\236j\341"} track {gid: "\241\352\236\271\245\310K?\206n\350>^\256\350\236"} track {gid: "\001\3648\210{&E\214\240\227p\325\201\021\211\325"} track {gid: "\325\304m\t\232\035Hg\224\325\314\007\207R8)"} track {gid: "l\265\035\333\342\233JL\244%\230\242\255\010\341W"} track {gid: "\242{\351V\"TIB\226\227\361Dn\376\352\325"} track {gid: "\035/@\'\326"} track {gid: "\217\\\322K\026\333N\301\256\334F\316\317F\255\177"} track {gid: "\371\260\370t\212fB;\205\002\372\212\353o\004\225"} track {gid: "\005\0314\362\325nHd\225Z\247\237H\334p!"} track {gid: "]\032\347\"\334\033Mb\267\003>\256\277\204@\302"} track {gid: "e.\022\244\242\265B\001\256\3224-D\003\370\027"} track {gid: "\r\326c\201\356\206C\353\272_\r\216\323\221\215\363"} track {gid: "\0226\367\033]\305J\371\205\3010lm\247M\277"} track {gid: "\370\ti\333h\215@\265\232\265\214\214;.\377\313"} track {gid: "Y\354bk\307uM\272\263\023\223\010\216q\276\t"} track {gid: "?}\246\"\205\231I\374\274<\222\003\032\217\220\023"} track {gid: "\351\211b\010\365!E*\255\344\031{\315\340R\300"} track {gid: "\027\033\235@\376\313M\343\277\243\240t6\2141\027"} track {gid: "\310\232\023\r\027TK\303\217\003&&\310.\305\220"} track {gid: "\216\353\244\214\034\341C\267\264\266\212\300h\027\315\263"} track {gid: "\177;p\361\343\231L\\\202Ae\006\230\t\235\252"} track {gid: "\000t\253\334\035\205H\376\224\001s\251?\213\321\202"} track {gid: "\374\023NxkGB@\252\331\2176\333\007\366\302"} track {gid: "u\036\242J\374tLr\271T\253\263\001\206{Z"} track {gid: "\214K\316\243t\256Oc\211\3054\335Q9\026/"} track {gid: "\262\373\357\221\230\335G\266\201\2537 9\376\335@"} track {gid: "\230\235\366AU\213M \227\020\254\177\310R\003x"} track {gid: "|-\246\224\375\312L\313\212\027%\230,\314dP"} track {gid: "\207\\M\027\345ENO\206^\340\177\263j\374\322"} track {gid: "f\372\362\202\257\032A\375\224rx\3331\tX\233"} track {gid: "\303\254\216\341\256\234H)\244&\033O\326\270O|"} track {gid: "\016\'\305xg2F\250\231\253\272\031ooQ\257"} track {gid: "|\353o&\310\306@b\232\032\305p\213\324\262\270"} track {gid: "\373\305v\245\334\277AR\241\273\253\001\332W\371\303"} track {gid: "\013\346\375\n\362\273D\333\216\206f\020\365\250\315\267"} track {gid: "\371\r\340t\226lNi\232\261\370\021f\2664\022"} track {gid: "\364y\226u\207\226Fl\256\247\245\214\013\213@A"} track {gid: "j\010,}\240\321G\232\2546\210\341\026E\3776"} track {gid: "\353\251J\013\245 L,\230\221\271V\304\262I\""} track {gid: "\214~\343\357\032#O3\273\003S\271\235f-("} track {gid: "\024\221\257\021\331\346F\027\260h9\002\327\363k\005"} track {gid: "\351]\346\022\216\276Ad\257u\210G\241\360y\211"} track {gid: "\304\261\316x\253U@\025\232,T\344!\362\233\014"} track {gid: "J\244\3749i\025A2\260j\245\334\307h\301\275"} track {gid: "G\235\034\\n\035F\272\214\223\337\303\352\025Y\226"} track {gid: "\277\025Lyz\023I;\213\225\351\246@\277\307\306"} track {gid: "\310[}C\036\030FE\266\315\365E}\201\362O"} track {gid: "\306p\250\253\266\321E\312\273\345\210}\014d\361~"} track {gid: "\256\004m\010\026eGe\252M\260\266\234\254\334\370"} track {gid: "\236\202\352\373\203\313A<\250\n\231OqX\022\362"} track {gid: "U\337\335\273\037\336G\351\237H\035\237?\244\340p"} track {gid: "\360\262(6\033gDp\216\344\300\274/\257\0261"} track {gid: "sR\253\224B{M\202\256\326\321\3713\232\317k"} track {gid: "8\251z\332\244@D\230\224S\203\'m\206\325\334"} track {gid: "\345?R\'\247\330I\362\217\320\034\002\360\031\267\325"} track {gid: "\265\372\351\000\271kM\326\232\341\241z \226\200\357"} track {gid: "Y2|\366$\245F\001\263\366\031\274e\030\202;"} track {gid: "\233(\301c(\201M\237\272f\026\362H\361,\371"} Frame has 81 tracks Sending status to server: [kPlayStatusPlay] command=SetAutoNormaliseAsAlbum(false) command=Load(SpotifyId { id: 320161834908296850438764581895649043041, audio_type: Track }, true, 19098) Sending status to server: [kPlayStatusPlay] Loading with Spotify URI Downloading file ad9d96330e3bf746d37fa1cd2763b785084d6fad new ChannelManager kMessageTypeNotify "Pixel 6" 07d93ca34490b752c30032f3eaf210a6424d4942 1558171388 1693775285224 kPlayStatusStop new AudioKeyManager (180026 ms) loaded == Starting sink == Desired Frames per Buffer: 22050 Desired Frames per Period: 5512 Actual Frames per Buffer: 22050 Actual Frames per Period: 5512 Period Buffer size in bytes: 22048 Period Buffer capacity: 22048 Sending status to server: [kPlayStatusPlay] ==> kPlayStatusPlay File ad9d96330e3bf746d37fa1cd2763b785084d6fad complete ```

Versions (please complete the following information):

Additional context Config File:

# Fill this in with your Spotify login.
username = "1doctorproctor1"
password = [REDACTED]

# How this machine shows up in Spotify Connect.
device_name = "spotifyd"
device_type = "computer"

use_mpris = true

volume_controller = "alsa"

(Also I just noticed that --verbose hides the username in the "CliConfig" line for privacy, but not later on, which is not very private)

slondr commented 11 months ago

that's a pretty old version, try upgrading.

nsklyarov commented 9 months ago

I've faced with something similar; Operating System Type: linux-gnueabihf Spotifyd 0.3.5 cargo 1.72.0 playerctl v2.4.1

eladyn commented 9 months ago

Has your spotifyd binary MPRIS support built in? As in: Did you install the full binary and enable the use_mpris flag?

nsklyarov commented 9 months ago

I'm not sure about full install but I've build this bin with cargo by faq from this page: https://docs.spotifyd.rs/installation/Ubuntu.html

and restart spotifyd service with these params:

backend = "alsa"
use_mpris = true
dbus_type = "session"

In unit logs I seeing these:

 Couldn't read volume from alsa device with name "default".
 Couldn't set volume: "Couldn't find selem with name 'Master'."
eladyn commented 9 months ago

Which audio backend were you using before? Otherwise, you'll need to find the correct configuration, e.g. using aplay -L.

nsklyarov commented 9 months ago

I've resolved troubles with volume control. playerctl still No players found.

When I change on dbus_type = "system" I receive this exception:

Message: Failed to register dbus player name: D-Bus error: Connection ":1.119" is not allowed to own the service "org.mpris.MediaPlayer2.spotifyd.instance3022" due to security policies in the configuration file (org.freedesktop.DBus.Error.AccessDenied)

Maybe the reason is that I use Alsa with this dbus_type?

UPDATE: Seems relates to https://github.com/Spotifyd/spotifyd/issues/244

eladyn commented 9 months ago

Are you on a headless system? If so, you'll either need to make sure that a session dbus is available and accessible from spotifyd as well as playerctl.

Or you use dbus_type = "system" and roll your own controlling solution (since playerctl doesn't work with the system dbus), but that will require additional configuration to fix that security policy issue above. (See the other issue you linked for details on that.)

If you have a working session dbus, you can check that spotifyd is connecting correctly via

# dbus-monitor --session --monitor "type='signal',interface='org.freedesktop.DBus'"
...
signal time=1701811349.860905 sender=org.freedesktop.DBus -> destination=(null destination) serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.1266"
   string ""
   string ":1.1266"
signal time=1701811349.861010 sender=org.freedesktop.DBus -> destination=:1.1266 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.1266"
signal time=1701811349.861855 sender=org.freedesktop.DBus -> destination=(null destination) serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string "org.mpris.MediaPlayer2.spotifyd.instance215550"
   string ""
   string ":1.1266"
signal time=1701811349.861945 sender=org.freedesktop.DBus -> destination=:1.1266 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string "org.mpris.MediaPlayer2.spotifyd.instance215550"
Kodiak-Web commented 4 months ago

i'm experiencing this issue on as well on Ubuntu 23.10 with a rustup managed rust, spotifyd 0.3.5, use_mpris=true & dbus_type=session how do i build the "full" version? i ran cargo install spotifyd for installation. also, log says use_mpris: none

eladyn commented 4 months ago

You'll need to add --features dbus_mpris.

Kodiak-Web commented 4 months ago

ran cargo install spotifyd --features dbus_keyring,dbus_mpris,default,portaudio_backend,pulseaudio_backend,rodio_backend TIL how cargo features work ig a --features all would be nice

eladyn commented 4 months ago

Well, there's --all-features. ^^

acegallagher commented 3 months ago

Hey there, I was having the same issue. It turns out I was trying to use the session dbus from while starting from a systemd user unit. This meant that spotifyd didn't have the proper pointers to dbus via environment variable. The proper way to do this is by running:

systemctl --user import-environment; systemctl --user daemon-reload

... apparently. But I'm not sure when/where to do that. Probably via your DE 'autostart' if you have one. Once you've done that, all user units will import your environment on reload.