AudioServicesPlaySystemSound not playing through BluetoothA2DP device

Hello

We have an application that play some sound via the system sound APIs from the AudioToolbox framework.

AudioServicesCreateSystemSoundID(url as CFURL, &soundID)
AudioServicesPlaySystemSoundWithCompletion(soundID)

Our make sure that an active audio session is available before playing the system sound. But when the device is connected to a BluetoothA2DP device. The sound are played on through the device speaker and not through the bluetooth A2DP device.

Our AudioSesison is configured with the following categories

 [.allowBluetooth, .defaultToSpeaker, .allowBluetoothA2DP]

Sound played from the AVAudioPlayer are played on the allowBluetoothA2DP device with similar code.

Is this a bug in the AudioToolbox framework?

Hello @KevLeGoff, thank you for your post.

The sound are played on through the device speaker and not through the bluetooth A2DP device.

This behavior is expected. The documentation for AudioServicesPlaySystemSound states that the sound is played locally on the device speakers, and that audio routing is not used.

Based on the code snippet you shared, it seems you are playing audio from a file. In that case, you can use AVAudioPlayer, for example, to play it to a Bluetooth route.

Hello thank you for your answer.

We used the AudioServicesPlaySystemSound because we want to take into account the silent / do not disturb mode on the device. We do not want to play a sound when the device in silence mode.

If there a way to accomplish this with the AVAudioSession and an AVAudio player. We did not find any available API to check the silent mode status on the user device ?

AudioServicesPlaySystemSound not playing through BluetoothA2DP device
 
 
Q