Skip to main content
Version: 0.1.x

Custom Audio Track - React Native

We have introduced the ability to pass a custom Audio track for the Audio of the participants with different encoder configuration.

Creating a Custom Audio Track

  • You can create a Audio Track using createAudioTrack() method of VideoSDK.
  • This method can be used to create audio track using different encoding parameters.

Parameters

  • encoderConfig:

    • type: String
    • required: true
    • default: speech_standard
    • Allowed values : speech_low_quality | speech_standard | music_standard | standard_stereo | high_quality | high_quality_stereo
    • It will be the encoder configuration you want to use for Audio Track.
  • context

    • type: Context
    • required: true
    • Pass the Android Context for this parameter.

Returns

  • CustomStreamTrack

Example

try {
val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality",this)
} catch (e: JSONException) {
e.printStackTrace()
}

Using Custom Audio Track

Custom Track while initializing the meeting

If you are passing micEnabled: true in the initMeeting of VideoSDK and want to use custom tracks from start of the meeting, you can pass custom track in the initMeeting as shown below.

override fun onCreate(savedInstanceState: Bundle?) {
//..

val customTracks: MutableMap<String, CustomStreamTrack> = HashMap()

val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", this)
customTracks["mic"] = audioCustomTrack //Key must be "mic"

// create a new meeting instance
val meeting = VideoSDK.initMeeting(
this@MainActivity,meetingId,participantName,
//MicEnabled , If true, it will use the passed custom track to turn mic on
true,
//WebcamEnabled
true,
//ParticipantId
null,
//Mode
null,
//Pass the custom tracks here
customTracks
)
}

Custom Track with unmuteMic()

In order to switch tracks during the meeting, you have to pass the CustomStreamTrack in the unmuteMic() method of Meeting.

You can also pass custom track in changeMic() method of Meeting.

note

Make sure to call muteMic() before you create a new track as it may lead to unexpected behavior.

try {
val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", this)
meeting!!.unmuteMic(audioCustomTrack)

//or
meeting!!.changeMic(AppRTCAudioManager.AudioDevice.BLUETOOTH, audioCustomTrack)
} catch (e: JSONException) {
e.printStackTrace()
}

Got a Question? Ask us on discord