createCustomAudioTrack
Creates a custom audio track.
Future<int> createCustomAudioTrack( {required AudioTrackType trackType, required AudioTrackConfig config});
Details
Attention: Ensure that you call this method before joining a channel.
To publish a custom audio source, see the following steps:
- Call this method to create a custom audio track and get the audio track ID.
- Call joinChannel to join the channel. In ChannelMediaOptions, set publishCustomAudioTrackId to the audio track ID that you want to publish, and set publishCustomAudioTrack to
true
. - Call pushAudioFrame and specify trackId as the audio track ID set in step 2. You can then publish the corresponding custom audio source in the channel.
Parameters
- trackType
- The type of the custom audio track. See AudioTrackType.Attention: If audioTrackDirect is specified for this parameter, you must set
publishMicrophoneTrack
tofalse
in ChannelMediaOptions when calling joinChannel to join the channel; otherwise, joining the channel fails and returns the error code -2. - config
- The configuration of the custom audio track. See AudioTrackConfig.
Returns
- If the method call is successful, the audio track ID is returned as the unique identifier of the audio track.
- If the method call fails, 0xffffffff is returned.