Browse Source

fix(ios): 修复耳机检测逻辑以正确应用音频会话配置

重构耳机检测逻辑,使用统一的 `detectHeadphonesOutput` 方法替代分散的端口类型检查,提高代码可维护性并确保音频会话配置在不同耳机类型下的一致性。
newdev_shunjiawei
liwei1dao 9 months ago
parent
commit
98a57c6235
  1. 2
      local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift

2
local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift

@ -1467,7 +1467,7 @@ private func applyAudioSessionForTTS() -> Bool {
let hasWiredHeadphones = outputs.contains(where: { $0.portType == .headphones || $0.portType == .headsetMic })
let hasBluetoothA2DP = outputs.contains(where: { $0.portType == .bluetoothA2DP || $0.portType == .bluetoothLE })
let hasBluetoothHFP = outputs.contains(where: { $0.portType == .bluetoothHFP })
let hasHeadphones = hasWiredHeadphones || hasBluetoothA2DP || hasBluetoothHFP
let hasHeadphones = self.detectHeadphonesOutput()
let otherAudioPlaying = audioSession.isOtherAudioPlaying
let isRecording = (self.micCapture?.isCapturing == true)
self.isHeadphones = hasHeadphones

Loading…
Cancel
Save