Skip to content

Feature/macos nowplaying - #1430

Open
drselump14 wants to merge 2 commits into
Spotifyd:masterfrom
drselump14:feature/macos-nowplaying
Open

drselump14 wants to merge 2 commits into
Spotifyd:masterfrom
drselump14:feature/macos-nowplaying

Conversation

@drselump14

Copy link
Copy Markdown

No description provided.

…moteCommandCenter)

spotifyd's existing dbus_mpris (MPRIS) integration has no consumer on macOS,
so it never shows up in Control Center, the lock screen, or responds to
hardware media keys the way a real app does (Spotifyd#316, Spotifyd#956).

Add an opt-in macos_media_remote feature (macOS-only, off by default) that
uses the souvlaki crate to talk directly to Apple's MediaPlayer framework.
It's driven by the same PlayerEvent stream dbus_mpris already consumes, and
forwards commands straight to the existing Spirc control handle -- no D-Bus
involved, so this runs independently of, and alongside, dbus_mpris.
macOS's mediaremoted arbitrates a single system-wide "Now Playing app".
A process can win that slot on a cold start when nothing else is
claiming it, but once another app (Music.app, another Spotify Connect
client) takes it, a plain background process calling
MPNowPlayingInfoCenter/MPRemoteCommandCenter APIs can never win it
back -- set_metadata/set_playback keep returning success but macOS
silently ignores them.

The fix is to give spotifyd a real, live Cocoa run loop instead of a
one-shot NSApplication touch: the tokio runtime and all of spotifyd's
actual work now run on a dedicated background thread, while the real
OS main thread spends the rest of the process's life inside
NSApplication::run (as an accessory app, no Dock icon). Verified this
is what actually matters by comparing against a Python/PyObJC
prototype that relied on AppHelper.runConsoleEventLoop() -- it
survived the same contest-and-quit scenario where the bare-API
approach didn't.

Also adds a 1s heartbeat that keeps re-asserting the current playback
state between PlayerEvents, since macOS evicts a claim it hasn't seen
refreshed in a while and falls back to launching Music.app.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant