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.
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)
}
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.
let roomId = "live_100001"
self.liveCoreView.joinLiveStream(roomId: roomId) { roomInfo in
} onError: { code, message in
}
String roomId = "live_100001";
liveCoreView.joinLiveStream(roomId, 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?