MPRIS bridge for the Music Assistant web player
  • Go 95.5%
  • Shell 4.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ladislav Brodecký 6706b25df1 Cache cover art locally and publish it as file://
noctalia loads mpris:artUrl only from file:// (its own http fetch of the
MA image proxy got a Cloudflare HTML page). Download the cover through
MA_URL on the LAN into ~/.cache/ma-mpris and hand widgets the local path.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-17 12:17:27 +02:00
.gitignore MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
art.go Cache cover art locally and publish it as file:// 2026-10-17 12:17:27 +02:00
go.mod MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
go.sum MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
LICENSE MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
ma-mpris.service MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
ma.go MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
main.go Cache cover art locally and publish it as file:// 2026-10-17 12:17:27 +02:00
mpris.go MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
PKGBUILD Cache cover art locally and publish it as file:// 2026-10-17 12:17:27 +02:00
README.md Cache cover art locally and publish it as file:// 2026-10-17 12:17:27 +02:00
state.go MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00
state_test.go MPRIS bridge for the Music Assistant web player 2026-10-17 12:13:33 +02:00

ma-mpris

MPRIS most pro vestavěný web player Music Assistantu. Zrcadlí přehrávač „Web (… on Linux)“ ze serveru MA jako org.mpris.MediaPlayer2.musicassistant na session busu, takže panel (noctalia, waybar, playerctl…) ukáže, co hraje, a media klávesy ho ovládají.

Proč

Web player MA (Sendspin) hraje přes Web Audio API bez <audio> elementu. Firefox/Zen pro takovou stránku MPRIS nevystaví (Mozilla bug 2067534) a media-element režim Sendspinu nepomůže: Firefox odmítá media control pro element napájený z MediaStream (HTMLMediaElement::ShouldStartMediaControlKeyListener, „media is real-time“). Jediná cesta mimo prohlížeč je tedy most přes MA API.

Jak to funguje

  • Každou sekundu POST /api players/all + player_queues/all, vybere dostupný Sendspin přehrávač, jehož jméno odpovídá regexu (výchozí ^Web \(.*Linux\)), přednost má hrající.
  • Stav, metadata (název, interpreti, album, cover, délka), pozice, hlasitost, shuffle a repeat jdou do MPRIS properties; Seeked se emituje při skoku.
  • Příkazy Play/Pause/Stop/Next/Previous/Seek/SetPosition, Volume, Shuffle a LoopStatus se posílají zpět do MA (player_queues/*, players/cmd/volume_set).
  • Bez odpovídajícího přehrávače (záložka zavřená) se most z busu odhlásí, widgety ho tedy neukazují.

Po pauze hlásí MA web player stav idle, proto MPRIS říká Stopped, ne Paused. Play frontu obnoví.

Konfigurace

~/.music-assistant.env (mode 600):

MA_URL=http://homeassistant.lan:8095
MA_TOKEN=<long-lived token z MA: Settings → Profile>
# volitelně: regex na jméno přehrávače
# MA_MPRIS_PLAYER=^Web \(.*Linux\)

Instalace (CachyOS/Arch)

makepkg -sf && sudo pacman -U ma-mpris-*.pkg.tar.zst
systemctl --user enable --now ma-mpris

Update: git pull, bump pkgver v PKGBUILD (nebo už bumpnutý z repa), znovu makepkg -sf && sudo pacman -U …, systemctl --user restart ma-mpris. Odinstalace: systemctl --user disable --now ma-mpris && sudo pacman -R ma-mpris.

Vývoj

go test ./... && go vet -stdmethods=false ./...   # Seek je jméno D-Bus metody, ne io.Seeker
go run . --once                                    # jen ukáže, který přehrávač by zrcadlil

Cover

Widgety (noctalia) načtou mpris:artUrl jen z file://, http(s) nechají „unresolved“. Most proto cover stáhne do ~/.cache/ma-mpris/ a publikuje lokální cestu; soubory starší 30 dnů maže při startu.