Feature/macos nowplaying - #1430
Open
drselump14 wants to merge 2 commits into
Open
drselump14 wants to merge 2 commits into
drselump14 wants to merge 2 commits into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.