Instance Method

setPreferredDataSource(_:)

Sets the preferred audio data source for the port.

Declaration

func setPreferredDataSource(_ dataSource: AVAudioSessionDataSourceDescription?) throws

Parameters

dataSource

The data source to be used.

Return Value

true if a request was successfully made, or false otherwise.

Discussion

Requests a change of data source; to determine whether the change takes effect, use the selectedDataSource property. (See “Configuring the Audio Session” in the AVAudioSession class reference for details.)

If the port is in use, changing this setting will likely result in a route reconfiguration.

Set a preferred data source only after setting the audio session’s category and mode and activating the session.

See Also

Managing a Port’s Data Sources

var dataSources: [AVAudioSessionDataSourceDescription]?

The available data sources for the port.

var selectedDataSource: AVAudioSessionDataSourceDescription?

The currently selected audio data source for the port.

var preferredDataSource: AVAudioSessionDataSourceDescription?

The preferred audio data source for the port.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software