From 4c0dfaaada6708d1cb4434ed28a8dd1508c9542e Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Tue, 16 Jun 2026 14:10:49 +0200 Subject: [PATCH] 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 f04bfb3d355f95152df4837cf117ebc7668387f3) --- src-tauri/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 3fcc7b06..16e3a98e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -502,11 +502,20 @@ pub fn run() { let app_handle = app.handle().clone(); if let Err(e) = controls.attach(move |event: MediaControlEvent| { match event { - MediaControlEvent::Toggle - | MediaControlEvent::Play - | MediaControlEvent::Pause => { + // Keep Play/Pause distinct from Toggle: the OS + // (notably macOS on audio-route changes, e.g. a + // 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", ()); } + MediaControlEvent::Play => { + let _ = app_handle.emit("media:play", ()); + } + MediaControlEvent::Pause => { + let _ = app_handle.emit("media:pause", ()); + } MediaControlEvent::Next => { let _ = app_handle.emit("media:next", ()); }