This document mainly introduces how to use SeatGridView
to listen to a certain host's live broadcast.
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 SeatGridView
import RTCRoomEngine
class ListenController: 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 ListenActivity 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));
}
}
Step 2: Listening
Call joinVoiceRoom
to enter a host's live room for listening.
let roomId = "voice_100001"
self.seatGridView.joinVoiceRoom(roomId: roomId) { roomInfo in
} onError: { code, message in
}
String roomId = "live_100001";
seatGridView.joinVoiceRoom(roomId, new TUIRoomDefine.GetRoomInfoCallback() {
@Override
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
}
@Override
public void onError(TUICommonDefine.Error error, String message) {
}
});
When you want to leave the live room, you can call the leaveVoiceRoom API.
self.seatGridView.leaveVoiceRoom {
} onError: { code, message in
}
seatGridView.leaveVoiceRoom( new , new TUIRoomDefine.GetRoomInfoCallback() {
@Override
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
}
@Override
public void onError(TUICommonDefine.Error error, String message) {
}
});
When the host dismisses the room, you will receive the onRoomDismissed
callback.
func onRoomDismissed(roomId: String) {
}
void onRoomDismissed(String roomId) {
}
Was this page helpful?