title: Taro.getAvailableAudioSources(option)

sidebar_label: getAvailableAudioSources

Gets supported audio input sources.

Reference

Type

  1. (option?: Option) => Promise<SuccessCallbackResult>

Parameters

Option

Property Type Required Description
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

SuccessCallbackResult

Property Type Description
audioSources ("auto" | "buildInMic" | "headsetMic" | "mic" | "camcorder" | "voice_communication" | "voice_recognition")[] The list of supported audio input sources. It can be used in the APIRecorderManager.start(). For the definitions of returned values, please see https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource
errMsg string Call result

audioSources

Valid values of res.audioSources

Property Description
auto Automatic setup. The mobile microphone is used by default. The headset microphone is automatically adopted when the headset is plugged in. This setup applies to all platforms.
buildInMic Mobile microphone for iOS only
headsetMic Headset microphone for iOS only
mic Microphone (if the headset is not plugged in, the mobile microphone is used; otherwise, the headset microphone is used) for Android only
camcorder Same as mic. Suitable for audio and video recording. For Android only.
voice_communication Same as mic. Suitable for real-time communication. For Android only.
voice_recognition Same as mic. Suitable for speech recognition. For Android only.

API Support

API WeChat Mini-Program H5 React Native
Taro.getAvailableAudioSources ✔️