kAudioSessionProperty_OverrideCategoryDefaultToSpeaker

1 kAudioSessionProperty_OverrideCategoryDefaultToSpeaker

指定,在没有耳机和听筒等输出设备的时候,是否将音频通过扬声器输出;

Discussion
A read/write UInt32 value. By default, the value of this property is FALSE (0).
This property retains its value through an audio route change (such as when plugging in or unplugging a headset), and upon interruption; it reverts to its default value only upon an audio session category change. This property can be used only with the kAudioSessionCategory_PlayAndRecord (or the equivalent playAndRecord) category.
See also kAudioSessionProperty_OverrideAudioRoute.

注意这个属性只支持 category为playandrecord,不支持什么playback之类的;如果你用的不是playandrecord,那当设置这个speaker属性的时候会报错-50;

 

https://developer.apple.com/documentation/audiotoolbox/kaudiosessionproperty_overrideaudioroute

2 kAudioSessionProperty_OverrideAudioRoute

Specifies whether or not to override the audio session category’s typical audio route

A write-only UInt32 value. Can be set with one of two values: kAudioSessionOverrideAudioRoute_None, which specifies that you want to use the typical audio route; and kAudioSessionOverrideAudioRoute_Speaker, when sends output audio to the built-in speaker. This property can be used only with the kAudioSessionCategory_PlayAndRecord (or the equivalent playAndRecord) category.
If a headset is plugged in at the time you set this property’s value to kAudioSessionOverrideAudioRoute_Speaker, the system changes the audio routing for input as well as for output: input comes from the built-in microphone; output goes to the built-in speaker.
Upon an audio route change (such as by plugging in or unplugging a headset), or upon interruption, this property reverts to its default value.

 

posted on 2022-03-17 10:40  邗影  阅读(99)  评论(0编辑  收藏  举报

导航