Skip to content

fix(playback): sync play/pause button with media keys - #43

Open
mihaimetal wants to merge 2 commits into
NUber-dev:mainfrom
mihaimetal:fix/media-key-play-pause-ui
Open

fix(playback): sync play/pause button with media keys#43
mihaimetal wants to merge 2 commits into
NUber-dev:mainfrom
mihaimetal:fix/media-key-play-pause-ui

Conversation

@mihaimetal

Copy link
Copy Markdown

Summary

  • Keep the player play/pause icon in sync when OS media keys (e.g. macOS F8) toggle playback.
  • On macOS, hardware media keys often pause/resume the WebKit <audio> element directly instead of going through the souvlaki media-control path, so sound changed but the store’s playing flag (and thus the button) did not.
  • Mirror element play / pause events into the playback store.
  • Briefly suppress that sync during intentional track-switch pauses so auto-advance still keeps playing: true.

Test plan

  • Play a track, press F8 (media play/pause) — audio pauses and the player button switches to Play
  • Press F8 again — audio resumes and the button switches to Pause
  • In-app play/pause button and Space still work
  • Skipping tracks still auto-resumes without the button flipping to Play mid-switch
  • macOS release build smoke-tested

Notes

Independent of the WEB_REMIX / auth / packaging PRs; can merge on its own against main.

@mihaimetal
mihaimetal force-pushed the fix/media-key-play-pause-ui branch from 7bddad5 to 1d3fe0b Compare July 27, 2026 13:43
@mihaimetal

Copy link
Copy Markdown
Author

Rebased onto current main after 0.4.0 (play/pause media-key sync, F7/F9 previous/next, stable WK data store).

macOS media keys (F8) often toggle the WebKit <audio> element directly
without going through our store. Mirror element play/pause events into
playing so the UI icon stays correct, and suppress that sync briefly
during intentional track-switch pauses.
Register navigator.mediaSession action handlers so WKWebView routes
hardware previous/next while HTML audio is playing, and attach skip
commands on MPRemoteCommandCenter (no Accessibility / event taps).

Also debounce skip paths and keep Media Session metadata in sync with
souvlaki Now Playing updates.
@mihaimetal
mihaimetal force-pushed the fix/media-key-play-pause-ui branch from 6f05b94 to 8866611 Compare August 2, 2026 18:27
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