【发布时间】:2020-07-03 04:41:31
【问题描述】:
我正在尝试混合音频源,以便没有音频闪避。我试图解决的用例是在后台进行音频通话,同时播放音乐和/或收听应用程序音频,没有任何音频闪避。音频闪避是指音频被降低并略微失真以帮助收听另一个音频会话。我可以不加掩饰的音频和音频混合(或 iOS)吗?
我已经尝试了以下代码。我也尝试将它包装在 DispatchQueue.main.async 闭包中,但仍然没有运气。
// I have also tried this code with this block uncommented
// do {
// try audioSession.setActive(false, options: .notifyOthersOnDeactivation)
//
// } catch let activationError {
// print(activationError)
// print(activationError.localizedDescription)
// }
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(
AVAudioSession.Category.playAndRecord,
mode: AVAudioSession.Mode.voiceChat,
options: [.allowBluetoothA2DP, .allowBluetooth, .mixWithOthers, .allowAirPlay]
)
} catch let setCategoryError {
print(setCategoryError)
print(setCategoryError.localizedDescription)
}
do {
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
} catch let activationError {
print(activationError)
print(activationError.localizedDescription)
}
【问题讨论】:
-
这个问题也适用于其他 WebRTC 调用,而不仅仅是 Agora。例如使用 OpenVidu。