From 8069683bd3c71cefd3dc3fd59e78bf0a0e188518 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sun, 16 Aug 2026 09:00:49 +0200 Subject: [PATCH] fix(ios): give music playback lock-screen and headphone controls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Music on iOS played through a mixable audio session: mpv's audiounit output requests mixWithOthers unless audio-exclusive is set, and a mixable session disqualifies the app from Now Playing. iOS ignored the published metadata and remote-command targets, so the lock screen showed no controls, headphone buttons drove the previous media app, and other apps kept playing alongside plezy. Set audio-exclusive on the audio-only core at init on iOS — the same contract the video player already applies at playback start. Its only effect there is dropping mixWithOthers. close #1921 --- lib/mpv/player/player_native.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/mpv/player/player_native.dart b/lib/mpv/player/player_native.dart index ae3f5a169..97e974e75 100644 --- a/lib/mpv/player/player_native.dart +++ b/lib/mpv/player/player_native.dart @@ -240,6 +240,15 @@ class PlayerNative extends PlayerBase { // setProperty() would await _ensureInitialized and deadlock on the // memoized future of this very _doInitialize call. await invoke('setProperty', {'name': 'gapless-audio', 'value': 'weak'}); + // ao_audiounit requests mixWithOthers unless audio-exclusive is set, + // and a mixable session disqualifies the app from iOS Now Playing — + // no lock-screen/headphone controls (#1921). Same contract as the + // video path (VideoPlayerScreen sets it at playback start). iOS-only: + // elsewhere audio-exclusive means exclusive device access (hog-mode + // CoreAudio on macOS, exclusive WASAPI on Windows). + if (Platform.isIOS) { + await invoke('setProperty', {'name': 'audio-exclusive', 'value': 'yes'}); + } } if (_nativeCoreUnavailable) throw StateError('Player was disposed during initialization');