configureAudioEnvironment
Configures the audio environment used by the conversation runtime.
Declaration
public func configureAudioEnvironment(
mode: STAudioEnvironmentMode = .default,
options: STAudioEnvironmentOptions = [
.allowBluetoothHFP,
.allowBluetoothA2DP,
.mixWithOthers
]
) -> STResultOverview
Configures the audio session/environment for subsequent media operations. The mode defaults to .default and options defaults to an empty option set ([]), so no additional routing or mixing options are requested unless supplied. For an application that needs Bluetooth headset microphone input, consider .allowBluetoothHFP; for Bluetooth playback, consider .allowBluetoothA2DP; for speaker routing, consider .defaultToSpeaker. Use .mixWithOthers only when the application should coexist with other audio. Choose options according to your audio-routing requirements rather than enabling all options unconditionally.
Note the defaults differ from calling STMediaRunner.configureAudioEnvironment directly: the conversation layer enables Bluetooth HFP, Bluetooth A2DP, and mixing with other audio by default.
Audio setup
Configure the audio environment after initialization and before starting media-dependent conversation processing. Use the mode and options appropriate to the application.
Usage example
_ = conversation.configureAudioEnvironment()
Result handling
This method returns an STResult. Check the returned value for success or failure.