my.getAvailableAudioSources

The my.getAvailableAudioSources JSAPI is called to get the available audio input sources. This topic describes parameters of the JSAPI and provides sample code.

Parameters

Property

Type

Required

Description

success

Function

No

Callback function upon call success.

fail

Function

No

Callback function upon call failure.

complete

Function

No

Callback function upon call completion, regardless of success or failure.

success

The parameter is of the object type. The following table lists the properties:

Property

Type

Required

Description

audioSources

Array<String>

Yes

A list of supported audio input sources.

Valid values are shown in audioSources.

audioSources

Value

Description

auto

Automatic setting. Phone microphones are used by default. Headphone microphones are used when headphones are connected. This value is applicable to all platforms.

buildInMic

Phone microphones. This value is applicable to iOS only.

headsetMic

Headphone microphones. This value is applicable to iOS only.

mic

Microphones. Phone microphones are used when no headphones are connected. Headphone microphones are used when headphones are connected. This value is applicable to Android only.

Sample code

copy
my.getAvailableAudioSources ({
  success: function (res) {
    console.log ('getAvailableAudioSources success', res);
  },
  fail: function (err) {
    console.log ('getAvailableAudioSources fail', err);
  },
});