mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 14:55:43 +00:00
fix(media-controls): honour explicit Play/Pause from OS media keys
Toggle, Play and Pause from the OS media-control bridge (souvlaki) were
all collapsed onto the play-pause toggle event. On an audio-route change
(e.g. macOS sending an explicit Pause when headphones disconnect) this
turned the pause into a toggle, resuming paused playback on the new
output device.
Map Play and Pause to dedicated media:play / media:pause events (the
frontend handlers already exist); only a real toggle key emits
media:play-pause. Paused playback now stays paused across device changes.
Fixes #1094
(cherry picked from commit f04bfb3d35)
This commit is contained in:
+12
-3
@@ -502,11 +502,20 @@ pub fn run() {
|
|||||||
let app_handle = app.handle().clone();
|
let app_handle = app.handle().clone();
|
||||||
if let Err(e) = controls.attach(move |event: MediaControlEvent| {
|
if let Err(e) = controls.attach(move |event: MediaControlEvent| {
|
||||||
match event {
|
match event {
|
||||||
MediaControlEvent::Toggle
|
// Keep Play/Pause distinct from Toggle: the OS
|
||||||
| MediaControlEvent::Play
|
// (notably macOS on audio-route changes, e.g. a
|
||||||
| MediaControlEvent::Pause => {
|
// headphone disconnect) sends an explicit Pause,
|
||||||
|
// and collapsing all three into a toggle would
|
||||||
|
// resume paused playback on the new device (#1094).
|
||||||
|
MediaControlEvent::Toggle => {
|
||||||
let _ = app_handle.emit("media:play-pause", ());
|
let _ = app_handle.emit("media:play-pause", ());
|
||||||
}
|
}
|
||||||
|
MediaControlEvent::Play => {
|
||||||
|
let _ = app_handle.emit("media:play", ());
|
||||||
|
}
|
||||||
|
MediaControlEvent::Pause => {
|
||||||
|
let _ = app_handle.emit("media:pause", ());
|
||||||
|
}
|
||||||
MediaControlEvent::Next => {
|
MediaControlEvent::Next => {
|
||||||
let _ = app_handle.emit("media:next", ());
|
let _ = app_handle.emit("media:next", ());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user