tanhakabir / SwiftAudioPlayer

Streaming and realtime audio manipulation with AVAudioEngine
https://medium.com/chameleon-podcast/creating-an-advanced-streaming-audio-engine-for-ios-9fbc7aef4115
MIT License
546 stars 108 forks source link

When i change input to BluetoothHFP, player is not working. #167

Open anjaeyoung26 opened 2 years ago

anjaeyoung26 commented 2 years ago
let options: AVAudioSession.CategoryOptions = [.mixWithOthers, .allowBluetoothA2DP, .allowBluetooth]

try session.setCategory(.playAndRecord, mode: .default, options: options)
try session.setActive(true)

if let inputs = session.availableInputs {
    for input in inputs {
        if input.portType == .bluetoothHFP {
            do {
                try session.setPreferredInput(input)
            } catch {
                print(error)
            }
        }
    }
}

I set audio session's input to BluetoothHFP for playing and recording music with Bluetooth mic. After changing the input, there is no sound even after restarting the player.