From 474dfc58ab075ac763ce7c4321adb3663bb032c0 Mon Sep 17 00:00:00 2001 From: kingslay Date: Fri, 22 Dec 2023 20:19:17 +0800 Subject: [PATCH] fix #698 --- Sources/KSPlayer/AVPlayer/KSOptions.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/KSPlayer/AVPlayer/KSOptions.swift b/Sources/KSPlayer/AVPlayer/KSOptions.swift index 9a8938ce6..01703a3ac 100644 --- a/Sources/KSPlayer/AVPlayer/KSOptions.swift +++ b/Sources/KSPlayer/AVPlayer/KSOptions.swift @@ -509,13 +509,17 @@ public extension KSOptions { var channelCount = channelCount if channelCount > 2 { let minChannels = min(maximumOutputNumberOfChannels, channelCount) - // iOS 有空间音频功能,所以不用处理 #if os(tvOS) || targetEnvironment(simulator) if !(isUseAudioRenderer && isSpatialAudioEnabled) { // 不要用maxRouteChannelsCount来判断,有可能会不准。导致多音道设备也返回2(一开始播放一个2声道,就容易出现),也不能用outputNumberOfChannels来判断,有可能会返回2 // channelCount = AVAudioChannelCount(min(AVAudioSession.sharedInstance().outputNumberOfChannels, maxRouteChannelsCount)) channelCount = minChannels } + #else + // iOS 外放是会自动有空间音频功能,但是蓝牙耳机有可能没有空间音频功能或者把空间音频给关了,。所以还是需要处理。 + if !isSpatialAudioEnabled { + channelCount = minChannels + } #endif } else { channelCount = 2