fix(ios): allow audio mixing when none of the players are playing (#4579)

This commit is contained in:
Lukas
2025-07-02 11:40:17 +03:00
committed by GitHub
parent 978683b645
commit 2d7e03942d

View File

@@ -139,6 +139,10 @@ class AudioSessionManager {
return view._playInBackground 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 let anyPlayerWantsMixing = videoViews.allObjects.contains { view in
return view._mixWithOthers == "mix" || view._mixWithOthers == "duck" return view._mixWithOthers == "mix" || view._mixWithOthers == "duck"
} }
@@ -150,7 +154,9 @@ class AudioSessionManager {
return return
} }
if canAllowMixing { if !anyPlayerPlaying {
options.insert(.mixWithOthers)
} else if canAllowMixing {
let shouldEnableMixing = videoViews.allObjects.contains { view in let shouldEnableMixing = videoViews.allObjects.contains { view in
return view._mixWithOthers == "mix" return view._mixWithOthers == "mix"
} }
@@ -199,7 +205,7 @@ class AudioSessionManager {
do { do {
try audioSession.setCategory( try audioSession.setCategory(
category, mode: .moviePlayback, options: canAllowMixing ? options : [] category, mode: .moviePlayback, options: options
) )
// Configure audio port // Configure audio port