feat(macos): drive the system Now Playing session through mpv
macOS has no D-Bus/MPRIS: the audio engine is what the OS media UI talks to. mpv's Cocoa backend registers with MPRemoteCommandCenter and MPNowPlayingInfoCenter, so it already publishes the live ICY title and receives the media keys. Add a platform-neutral media session (mediasession.py) so the app keeps a single interface: MprisService on D-Bus platforms, NowPlayingSession on macOS. Map mpv's NEXT/PREV/PLAY/PLAYONLY/PAUSEONLY/STOP keys onto script-messages and read them back as client-message IPC events, so the hardware media keys and Control Center drive the TUI (station changes, play/pause/stop) instead of fighting it. --no-mpris (now also --no-media) disables the media keys too. macOS-only mpv options are gated on sys.platform so the Linux command line is unchanged; mpv aborts on unknown flags.
This commit is contained in:
1 parent
d83a9ef03d
commit
9c722c5f61
8 files changed
+415
-37
No files matched your search
@@ -32,7 +32,8 @@ class StatusBar(Widget):
|
||||
width = max(20, self.size.width)
|
||||
glyph, colour = state_glyph(app.playing_state)
|
||||
frame = app.spectrum.snapshot()
|
||||
mpris = app.mpris.status_label
|
||||
session = app.media.label
|
||||
status = app.media.status_label
|
||||
backend = app.player.backend or "no audio"
|
||||
analyser = frame.label
|
||||
|
||||
@@ -44,19 +45,21 @@ class StatusBar(Widget):
|
||||
|
||||
# From most to least informative; pick the first combination that fits.
|
||||
right_variants = (
|
||||
f"{state} {listeners}{volume} {backend} mpris {mpris} {analyser}",
|
||||
f"{state} {listeners}{volume} {backend} {session} {status} {analyser}",
|
||||
f"{state} {volume} {session} {status} {analyser}",
|
||||
f"{state} {volume} {analyser}",
|
||||
f"{state} {volume}",
|
||||
volume,
|
||||
)
|
||||
options = (
|
||||
(HINTS_LONG, right_variants[0]),
|
||||
(HINTS_LONG, right_variants[1]),
|
||||
(HINTS_MEDIUM, right_variants[0]),
|
||||
(HINTS_LONG, right_variants[1]),
|
||||
(HINTS_MEDIUM, right_variants[1]),
|
||||
(HINTS_SHORT, right_variants[1]),
|
||||
(HINTS_SHORT, right_variants[2]),
|
||||
(HINTS_SHORT, right_variants[3]),
|
||||
(HINTS_SHORT, right_variants[4]),
|
||||
)
|
||||
|
||||
chosen: tuple[int, str, str] | None = None
|
||||
|
||||
Reference in new issue
Block a user