tencent cloud

Feedback

Tencent Real-Time Communication

Listening

Last updated: 2024-12-24 17:45:36
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.
iOS
Android
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)
// Add seatGridView to the view and set layout constraints
}
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.
iOS
Android
let roomId = "voice_100001" // Please replace it with the room ID of the host you want to listen to
self.seatGridView.joinVoiceRoom(roomId: roomId) { roomInfo in
// Listening succeeded
} onError: { code, message in
// Listening failed
}
String roomId = "live_100001"; // Please replace it with the room ID of the host you want to listen to
seatGridView.joinVoiceRoom(roomId, new TUIRoomDefine.GetRoomInfoCallback() {
@Override
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
// Successfully joined the live streaming room
}


@Override
public void onError(TUICommonDefine.Error error, String message) {
// Failed to join the live streaming room
}
});
When you want to leave the live room, you can call the leaveVoiceRoom API.
iOS
Android
self.seatGridView.leaveVoiceRoom {
// Successfully exited the live streaming room
} onError: { code, message in
// Failed to exit the live streaming room
}
seatGridView.leaveVoiceRoom( new , new TUIRoomDefine.GetRoomInfoCallback() {
@Override
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
// Successfully exited the live streaming room
}


@Override
public void onError(TUICommonDefine.Error error, String message) {
// Failed to exit the live streaming room
}
});
When the host dismisses the room, you will receive the onRoomDismissed callback.
iOS
Android
func onRoomDismissed(roomId: String) {
// The room has been dissolved
}
void onRoomDismissed(String roomId) {
// The room has been dissolved
}
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon