Skip to main content
Version: 3.x

Taro.getAvailableAudioSources(option)

Gets supported audio input sources.

Reference

Type

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

Parameters

Option

PropertyTypeRequiredDescription
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

SuccessCallbackResult

PropertyTypeDescription
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
errMsgstringCall result

audioSources

Valid values of res.audioSources

PropertyDescription
autoAutomatic 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.
buildInMicMobile microphone for iOS only
headsetMicHeadset microphone for iOS only
micMicrophone (if the headset is not plugged in, the mobile microphone is used; otherwise, the headset microphone is used) for Android only
camcorderSame as mic. Suitable for audio and video recording. For Android only.
voice_communicationSame as mic. Suitable for real-time communication. For Android only.
voice_recognitionSame as mic. Suitable for speech recognition. For Android only.

API Support

APIWeChat Mini-ProgramH5React Native
Taro.getAvailableAudioSources✔️