• 서비스
  • 가격
  • 리소스
  • 기술지원
이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

Audio Settings

this document primarily introduces how to use RTC Room Engine SDK to implement audio settings related features.

Prerequisites

Before using the audio settings related features provided by RTC Room Engine SDK, you need to complete log in to the SDK and ensure that you are in a live room.

User Guide

Turn On/Off Local Microphone

iOS
Android
You can turn on or off your local microphone by calling two APIs: openLocalMicrophone and closeLocalMicrophone.
When calling openLocalMicrophone to turn on the microphone, you need to input a parameter quality in types of TUIAudioQuality to set the audio encoding quality. TUIAudioQuality includes following types. You can select based on your business requirement:
Enumerated Value Type
Meaning
speech
Voice mode. Mono; Raw Bit Rate of audio: 18 kbps; suitable for scenarios mainly for voice calls.
default
Default mode. Mono; Raw Bit Rate of audio: 50 kbps; the default audio quality of the SDK. It is the recommended choice unless otherwise needed.
music
Music mode. Stereo + full-band; Raw Bit Rate of audio: 128 kbps; suitable for scenarios requiring high-quality music transmission, such as online karaoke, music live streaming.
You can turn on or off your local microphone by calling two APIs: openLocalMicrophone and closeLocalMicrophone.
When calling openLocalMicrophone to turn on the microphone, you need to input a parameter quality in types of AudioQuality to set the audio encoding quality. AudioQuality includes following types. You can select based on your business requirement:
Enumerated Value Type
Meaning
SPEECH
Voice mode. Mono; Raw Bit Rate of audio: 18 kbps; suitable for scenarios mainly for voice calls.
DEFAULT
Default mode. Mono; Raw Bit Rate of audio: 50 kbps; the default audio quality of the SDK. It is the recommended choice unless otherwise needed.
MUSIC
Music mode. Stereo + full-band; Raw Bit Rate of audio: 128 kbps; suitable for scenarios requiring high-quality music transmission, such as online karaoke, music live streaming.
Following is the example code for turning on and off the local microphone in default mode.
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()

// Turn on the local microphone
roomEngine.openLocalMicrophone(.default) {
// Successfully turn on the microphone
} onError: { code, message in
// Fail to turn on the microphone
}

// Turn off the local microphone
roomEngine.closeLocalMicrophone()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();
// Turn on the local microphone
roomEngine.openLocalMicrophone(TUIRoomDefine.AudioQuality.DEFAULT, new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
// Successfully turn on the microphone
}
@Override
public void onError(TUICommonDefine.Error error, String message) {
// Fail to turn on the microphone
}
});
// Turn off the local microphone
roomEngine.closeLocalMicrophone();

Update Local Audio Encoding Quality

iOS
Android
When updating the local audio encoding quality, the type of the passed parameters TUIAudioQuality needs to be consistent with what was mentioned in the previous context. Below, taking the default mode as an example, call the updateAudioQuality API to update the encoding quality of local audio:
import RTCRoomEngine

let audioQuality: TUIAudioQuality = .default
TUIRoomEngine.sharedInstance().updateAudioQuality(audioQuality)
When updating the local audio encoding quality, the type of the passed parameters AudioQuality needs to be the same as mentioned above. Below, taking the default mode as an example, call the updateAudioQuality API to update the encoding quality of local audio:
TUIRoomDefine.AudioQuality audioQuality = TUIRoomDefine.AudioQuality.DEFAULT;
TUIRoomEngine.sharedInstance().updateAudioQuality(audioQuality);

Pause/Resume Publishing Local Audio Stream

When you are in the live streaming room, you may need to pause/resume publishing your local audio stream. You can achieve this by calling the following interfaces:
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()

// Pause publishing local audio stream
roomEngine.muteLocalAudio()

// Resume publishing local audio stream
roomEngine.unmuteLocalAudio() {
// Resume publishing successful
} onError: { code, message in
// Resume publishing failed
}
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();

// Pause publishing local audio stream
roomEngine.muteLocalAudio();

// Resume publishing local audio stream
roomEngine.unmuteLocalAudio(new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
// Resume publishing successful
}

@Override
public void onError(TUICommonDefine.Error error, String message) {
// Restore publication failed
}
});
Note:
Inside the room, if you have enabled your microphone and called the above API to suspend/resume the publishing of the local audio stream, the SDK will notify users in the room through the onUserAudioStateChanged callback in TUIRoomObserver.