SpeechTilesAndamento Docs
Get started
SDK Reference · Type

STAudioEnvironmentOptions

An OptionSet containing audio-environment routing and mixing options.

Overview

Combine these options to request audio-session routing, mixing, or interaction behavior appropriate to the application. An empty option set means no additional options are requested. Choose options in conjunction with the selected audio environment mode and verify platform support.

public struct STAudioEnvironmentOptions: OptionSet, Sendable {
    public let rawValue: Int

    public init(rawValue: Int) {
        self.rawValue = rawValue
    }

    public static let mixWithOthers =
        STAudioEnvironmentOptions(rawValue: 1 << 0)

    public static let duckOthers =
        STAudioEnvironmentOptions(rawValue: 1 << 1)

    public static let interruptSpokenAudioAndMixWithOthers =
        STAudioEnvironmentOptions(rawValue: 1 << 2)

    public static let allowBluetoothHFP =
        STAudioEnvironmentOptions(rawValue: 1 << 3)

    public static let allowBluetoothA2DP =
        STAudioEnvironmentOptions(rawValue: 1 << 4)

    public static let allowAirPlay =
        STAudioEnvironmentOptions(rawValue: 1 << 5)

    public static let defaultToSpeaker =
        STAudioEnvironmentOptions(rawValue: 1 << 6)
}

Options can be combined:

let options: STAudioEnvironmentOptions = [
    .allowBluetoothHFP,
    .defaultToSpeaker
]

Select environment options

let options: STAudioEnvironmentOptions = [.allowBluetoothHFP, .allowBluetoothA2DP]
let result = STMediaRunner.shared.configureAudioEnvironment(options: options)

Purpose and usage

Combine audio session routing and mixing options when configuring the audio environment.

Properties

Swift example

let options: STAudioEnvironmentOptions = [.allowBluetoothHFP, .mixWithOthers]
_ = STMediaRunner.shared.configureAudioEnvironment(options: options)

Where this type is used

Using the audio environment

Select a supported audio environment mode and its optional routing/mixing options together. The defaults request .default mode and an empty options set; additional options should be chosen for a specific use case.

let result = STMediaRunner.shared.configureAudioEnvironment(
    mode: .default,
    options: []
)

See Also