fix(ios): give music playback lock-screen and headphone controls

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
This commit is contained in:
edde746
2026-08-16 09:00:49 +02:00
parent d1d393eec0
commit 8069683bd3
+9
View File
@@ -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');