RTC Room Engine
SDK to implement audio settings features.RTC Room Engine
SDK, you need to complete the SDK login and ensure that you are in a live room.openLocalMicrophone
and closeLocalMicrophone
APIs respectively.openLocalMicrophone
to turn on the microphone, you need to pass a parameter of type TUIAudioQuality
named quality
to set the audio encoding quality. TUIAudioQuality
includes the following types, which you can choose according to your business needs:Enumeration value types | Meaning |
speech | Voice mode. Mono; audio bitrate: 18kbps; suitable for voice call scenarios. |
default | Default mode. Mono; audio bitrate: 50kbps; the default audio quality of the SDK, recommended if there are no special requirements. |
music | Music mode. Stereo + full band; audio bitrate: 128kbps; suitable for scenarios requiring high-fidelity music transmission, such as online karaoke and music live streaming. |
openLocalMicrophone
and closeLocalMicrophone
APIs respectively.openLocalMicrophone
to turn on the microphone, you need to pass a parameter of type AudioQuality
named quality
to set the audio encoding quality. AudioQuality
includes the following types, which you can choose according to your business needs:Enumeration value types | Meaning |
SPEECH | Voice mode. Mono; audio bitrate: 18kbps; suitable for voice call scenarios. |
DEFAULT | Default mode. Mono; audio bitrate: 50kbps; the default audio quality of the SDK, recommended if there are no special requirements. |
MUSIC | Music mode. Stereo + full band; audio bitrate: 128kbps; suitable for scenarios requiring high-fidelity music transmission, such as online karaoke and music live streaming. |
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()// Turn on the local microphoneroomEngine.openLocalMicrophone(.default) {// Successfully turned on the mic} onError: { code, message in// Failed to turn on the mic}// Turn off the local microphoneroomEngine.closeLocalMicrophone()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();// Turn on the local microphoneroomEngine.openLocalMicrophone(TUIRoomDefine.AudioQuality.DEFAULT, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully turned on the mic}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to turn on the mic}});// Turn off the local microphoneroomEngine.closeLocalMicrophone();
TUIAudioQuality
is the same as mentioned above. Below is an example of using the default mode to call the updateAudioQuality
API to update the local audio encoding quality:import RTCRoomEnginelet audioQuality: TUIAudioQuality = .defaultTUIRoomEngine.sharedInstance().updateAudioQuality(audioQuality)
AudioQuality
is the same as mentioned above. Below is an example of using the default mode to call the updateAudioQuality
API to update the local audio encoding quality:TUIRoomDefine.AudioQuality audioQuality = TUIRoomDefine.AudioQuality.DEFAULT;TUIRoomEngine.sharedInstance().updateAudioQuality(audioQuality);
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()// Pause publishing local audio streamsroomEngine.muteLocalAudio()// Resume publishing local audio streamsroomEngine.unmuteLocalAudio() {// Resume publishing successful} onError: { code, message in// Resume publishing failed}
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();// Pause publishing local audio streamsroomEngine.muteLocalAudio();// Resume publishing local audio streamsroomEngine.unmuteLocalAudio(new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Resume publishing successful}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Resume publishing failed}});
TUIRoomObserver
callback onUserAudioStateChanged.
Was this page helpful?