Post not yet marked as solved
Post marked as unsolved with 1 replies, 419 views
let session = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSession.Category.playback)
try session.setActive(true)
//playAndRecord <AVAudioSessionPortDescription: 0x2828dc2b0, type = Speaker; name = 扬声器; UID = Speaker; selectedDataSource = (null)>
//playback <AVAudioSessionPortDescription: 0x28204c1a0, type = BluetoothA2DPOutput; name = M2; UID = 00:02:5C:22:22:11-tacl; selectedDataSource = (null)>
print(session.currentRoute.outputs)
} catch {
print(error)
}
when I ssession.setCategory(AVAudioSession.Category.playback) audio play output a2dp ble devices.
session.currentRoute.outputs print bellow
`<AVAudioSessionPortDescription: 0x28204c1a0, type = BluetoothA2DPOutput; name = M2; UID = 00:02:5C:22:22:11-tacl; selectedDataSource = (null)>
when I ssession.setCategory(AVAudioSession.Category.playAndRecord)
output
<AVAudioSessionPortDescription: 0x2828dc2b0, type = Speaker; name = 扬声器; UID = Speaker; selectedDataSource = (null)>
BluetoothA2DPOutput is gone.
but it is normal in ios15-16.
Is there any solution? I want to record audio and play music at the same time. And the music is output from the Bluetooth speaker