From 2d7e03942d5e2525e5c71dc914926ba07f67d54a Mon Sep 17 00:00:00 2001 From: Lukas <38685058+lukasjengo@users.noreply.github.com> Date: Wed, 2 Jul 2025 11:40:17 +0300 Subject: [PATCH] fix(ios): allow audio mixing when none of the players are playing (#4579) --- ios/Video/AudioSessionManager.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ios/Video/AudioSessionManager.swift b/ios/Video/AudioSessionManager.swift index 17c4a151..2f118609 100644 --- a/ios/Video/AudioSessionManager.swift +++ b/ios/Video/AudioSessionManager.swift @@ -139,6 +139,10 @@ class AudioSessionManager { return view._playInBackground } + let anyPlayerPlaying = videoViews.allObjects.contains { view in + return !view.isMuted() && view._player != nil && view._player?.rate != 0 + } + let anyPlayerWantsMixing = videoViews.allObjects.contains { view in return view._mixWithOthers == "mix" || view._mixWithOthers == "duck" } @@ -150,7 +154,9 @@ class AudioSessionManager { return } - if canAllowMixing { + if !anyPlayerPlaying { + options.insert(.mixWithOthers) + } else if canAllowMixing { let shouldEnableMixing = videoViews.allObjects.contains { view in return view._mixWithOthers == "mix" } @@ -199,7 +205,7 @@ class AudioSessionManager { do { try audioSession.setCategory( - category, mode: .moviePlayback, options: canAllowMixing ? options : [] + category, mode: .moviePlayback, options: options ) // Configure audio port