Microphone Management
This document mainly introduces the microphone management capabilities of
SeatGridView
.SeatGridView
supports the following microphone management capabilities:Prerequisites
Before using
SeatGridView
, you need to integrate and log in to SeatGridView to ensure the subsequent features work properly.Usage guide
Step 1: Adding SeatGridView to the View
You need to import the
SeatGridView
module first, then create a SeatGridView object and add it to your view.import UIKitimport RTCRoomEngineimport SeatGridViewclass SeatManagementController: UIViewController {private let seatGridView: SeatGridView = {let view = SeatGridView()return view}override func viewDidLoad() {super.viewDidLoad()self.seatGridView.addObserver(observer: self)// Add seatGridView to the view and set layout constraints}deinit {self.seatGridView.removeObserver(observer: self)}}
import com.trtc.uikit.livekit.seatGridView.SeatGridView;public class MicrophoneManagementActivity extends AppCompatActivity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);SeatGridView seatGridView = new SeatGridView(this);addContentView(seatGridView,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));seatGridView.addObserver(this);}@Overrideprotected void onDestroy() {super.onDestroy();seatGridView.removeObserver(this);}}
Step 2: Managing the Microphone
Start Microphone
Call
startMicrophone
to turn on the microphone.self.seatGridView.startMicophone {// Successfully turned on the mic} onError: { code, message in// Failed to turn on the mic}
seatGridView.startMicrophone(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}});
Stop Microphone
Call
stopMicrophone
to turn off the microphone.self.seatGridView.stopMicophone()
seatGridView.stopMicophone();
Mute Microphone
Call
muteMicrophone
to mute.self.seatGridView.muteMicrophone()
seatGridView.muteMicrophone();
Unmute Microphone
Call
unmuteMicrophone
to unmute.self.seatGridView.unmuteMicrophone {print("Unmuted successfully")} onError: { code, message inprint("Failed to unmute")}
seatGridView.unMuteLocalAudio(new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully unmuted}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// // Failed to unmute}});
When someone's microphone status changes, you will receive a callback
onUserAudioStateChanged
.func onUserAudioStateChanged(userInfo: TUIUserInfo, hasAudio: Bool, reason: TUIChangeReason) {if hasAudio {print("\(userInfo.userId) has audio")} else {print("\(userInfo.userId) has no audio")}}
void onUserAudioStateChanged(TUIRoomDefine.UserInfo userInfo, boolean hasAudio,TUIRoomDefine.ChangeReason reason) {// userInfo.userName's audio status changed}