이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

Watch

This document mainly introduces how to use the LiveStreamCore module's LiveCoreView to view the host's live stream.

Prerequisites

Before using LiveStreamCore, you need to integrate and log in to LiveStreamCore to ensure the subsequent features work properly.

Usage guide

Step 1: Adding LiveCoreView to the View

You need to first import the LiveStreamCore module, then create a LiveCoreView view object and add it to your view.
iOS
Android
import LiveStreamCore
import RTCRoomEngine

class WatchController: UIViewController {
private let liveCoreView: LiveCoreView = {
let view = LiveCoreView()
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.liveCoreView.registerConnectionObserver(observer: self)
// Add liveCoreView to the view and set layout constraints
}
deinit {
self.liveCoreView.unregisterConnectionObserver(observer: self)
}
}
public class WatchActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LiveCoreView liveCoreView = new LiveCoreView(this);
addContentView(liveCoreView,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
}

Step 2: Viewing

Call joinLiveStream to enter a host's live room for viewing.
iOS
Android
let roomId = "live_100001" // Please replace it with the room ID of the host you want to view
self.liveCoreView.joinLiveStream(roomId: roomId) { roomInfo in
// Successfully joined the live streaming room
} onError: { code, message in
// Failed to join the live streaming room
}
String roomId = "live_100001"; // Please replace it with the room ID of the host you want to view
liveCoreView.joinLiveStream(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 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
}