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 UIKit
import RTCRoomEngine
import SeatGridView
class SeatManagementController: UIViewController {
private let seatGridView: SeatGridView = {
let view = SeatGridView()
return view
}
override func viewDidLoad() {
super.viewDidLoad()
self.seatGridView.addObserver(observer: self)
}
deinit {
self.seatGridView.removeObserver(observer: self)
}
}
import com.trtc.uikit.livekit.seatGridView.SeatGridView;
public class MicrophoneManagementActivity extends AppCompatActivity {
@Override
protected 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);
}
@Override
protected void onDestroy() {
super.onDestroy();
seatGridView.removeObserver(this);
}
}
Step 2: Managing the Microphone
Start Microphone
Call startMicrophone
to turn on the microphone.
self.seatGridView.startMicophone {
} onError: { code, message in
}
seatGridView.startMicrophone(new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess () {
}
@Override
public void onError (TUICommonDefine.Error error, String message) {
}
});
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 in
print("Failed to unmute")
}
seatGridView.unMuteLocalAudio(new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(TUICommonDefine.Error error, String message) {
}
});
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) {
}
Was this page helpful?