Keep bluetooth sound when initializing AVAudioSession

后端 未结 2 1645
面向向阳花
面向向阳花 2020-12-06 18:28

I\'m about to go crazy.

I have a recording app. I\'m running into a problem that when I open my app, if i\'m listening to music on a bluetooth device, it gets autom

2条回答
  •  执念已碎
    2020-12-06 18:50

    With iOS 10, Apple added the option AVAudioSessionCategoryOptionAllowBluetoothA2DP. They also changed the meaning of AudioSessionCategoryOptionAllowBluetooth to only allow output using the HFP Bluetooth profile, which is where you get the low quality audio output.

    If you use this new option in place of the AudioSessionCategoryOptionAllowBluetooth option in your code snippet, it will allow high quality output but disallow low quality audio output.

    Here's the online documentation for the options, but unfortunately there's no description for the new iOS 10 options online. You can see more detail in the in-code documentation for AVAudioSession.h. https://developer.apple.com/reference/avfoundation/avaudiosessioncategoryoptions?language=objc

提交回复
热议问题