Platform | Version |
Flutter | Flutter 3.27.4 or later. Dart 3.6.2 or later. |
Android | Android Studio 3.5 or later. Android 5.0 or later Android devices. |
iOS | Xcode 15.0 or later. Ensure your project has a deemed valid developer signature. |
build.gradle.kts (or build.gradle) file and add the following code in it to join the dependency of the LiveCoreView component:api("io.trtc.uikit:live-stream-core:latest.release")
api 'io.trtc.uikit:live-stream-core:latest.release'
proguard-rules.pro file:-keep class com.tencent.** { *; }-keep class com.trtc.uikit.livekit.livestreamcore.** { *; }-keep class com.google.gson.** { *;}
AndroidManifest.xml file, add tools:replace="android:allowBackup" and android:allowBackup="false" in the application node, override the settings within the component, and use your own settings.// app/src/main/AndroidManifest.xml<application...// add the following configuration to overwrite the configuration in the dependent sdkandroid:allowBackup="false"tools:replace="android:allowBackup">=
pod 'LiveStreamCore' dependency in your Podfile file.target 'xxxx' do......pod 'LiveStreamCore'end
Podfile file, first cd to the xxxx.xcodeproj directory in the terminal, then create it through the following command:pod init
cd to the Podfile directory, then execute the following commands to install components.pod install
pod repo update
pod update
flutter pubaddlive_stream_core
TUIRoomEngine.login(applicationContext,1400000001, // replace with the SDKAppID obtained in step 1"denny", // replace with your UserID"xxxxxxxxxxx", // you can count a UserSig in the console and fill it in this locationobject : TUIRoomDefine.ActionCallback() {override fun onSuccess() {Log.i(TAG, "login success")}override fun onError(errorCode: Int, errorMessage: String) {Log.e(TAG, "login failed, errorCode: $errorCode msg:$errorMessage")}})
TUIRoomEngine.login(context,1400000001, // replace with the SDKAppID obtained in step 1"denny", // replace with your UserID"xxxxxxxxxxx", // you can count a UserSig in the console and fill it in this locationnew TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {Log.i(TAG, "login success");}@Overridepublic void onError(TUICommonDefine.Error error, String message) {Log.e(TAG, "login failed, errorCode: " + errorCode + " msg:" + errorMessage);}});
//// AppDelegate.swift//import RTCRoomEnginefunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {TUIRoomEngine.login(sdkAppId: 1400000001, // replace with SDKAppID obtained in step 1userId: "denny", // replace with your UserIDuserSig: "xxxxxxxxxxx") { // you can count a UserSig in the console and fill it in this locationprint("login success")} onError: { code, message inprint("login failed, code: \\(code), error: \\(message ?? "nil")")}return true}
RTCRoomEngine. This step is critical. Only after successfully logged in can you use the features provided by LiveStreamCore properly.final result = await TUIRoomEngine.login('Replace with your activated SDKAppID','Replace with your userId','Replace with your userSig');
Parameters | Type | Description |
SDKAppID | int | |
UserID | String | The current user ID, string type, only allows letters (a-z and A-Z), digits (0-9), hyphens, and underscores. |
userSig | String | Use the SecretKey obtained from Step 3 of Step 1 to encrypt information such as SDKAppID and UserID. This process generates a UserSig, which is an authentication token used by Tencent Cloud to verify whether the current user can use the TRTC service. You can generate a temporary UserSig using the auxiliary tool in the console. For more information, see how to calculate and use UserSig. |
GenerateTestUserSig.genTestSig function to generate userSig. In this method, the SDKSecretKey is very easy to decompile and reverse. Once your key is leaked, an attacker can steal your Tencent Cloud traffic.Anchor starts live | audience viewing the live stream |
![]() |
![]() |
dynamic grid layout | floating small window layout | fixed grid layout | fixed small window layout |
![]() | ![]() | ![]() | ![]() |
val livecoreView = LiveCoreView(this)
LiveCoreView liveCoreView = new LiveCoreView(this);
import LiveStreamCorelet liveCoreView = LiveCoreView()
LiveCoreController first, then assign value to the live streaming core component LiveCoreWidget.LiveCoreController is responsible for providing API, LiveCoreWidget is used to show the mic seat UI. You can add LiveCoreWidget anywhere you need to display the mic seat UI.import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final controller =LiveCoreController();LiveCoreWidget(controller: controller);
livecoreView.startCamera(true, null)
liveCoreView.startCamera(true, null);
import LiveStreamCoreliveCoreView.startCamera(useFrontCamera: true) {} onError: { code, message in}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';final startCameraResult = await controller.startCamera(true);
val liveInfo = TUILiveListManager.LiveInfo()liveInfo.roomId = "123456"/**Select layout: If you want to select another layout to go live, set liveInfo.seatLayoutTemplateId = 600600: dynamic grid layout (default)601: floating small window layout800: fixed grid layout801: fixed small window layout*/liveInfo.seatLayoutTemplateId = 600livecoreView.startLiveStream(liveInfo, null)livecoreView.startMicrophone(null)
TUILiveListManager.LiveInfo liveInfo = new TUILiveListManager.LiveInfo();liveInfo.roomId = "roomId_123456";/**Select layout: If you want to select another layout to go live, set liveInfo.seatLayoutTemplateId = 600600: dynamic grid layout (default)601: floating small window layout800: fixed grid layout801: fixed small window layout*/liveInfo.seatLayoutTemplateId = 600livecoreView.startLiveStream(liveInfo, null);livecoreView.startMicrophone(null);
import LiveStreamCoreimport RTCRoomEnginelet liveInfo = TUILiveInfo()liveInfo.roomId = "123456"liveInfo.seatMode = .applyToTake/**Select layout: If you want to select another layout to go live, set liveInfo.seatLayoutTemplateId = 600600: dynamic grid layout (default)601: floating small window layout800: fixed grid layout801: fixed small window layout*/liveInfo.seatLayoutTemplateId = 600liveCoreView.startLiveStream(liveInfo: liveInfo) { roomInfo in} onError: { code, message in}liveCoreView.startMicrophone {} onError: { code, message in}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';final roomInfo = TUIRoomInfo(roomId: '123456');roomInfo.name = 'replace with your roomName'roomInfo.isSeatEnabled = true;roomInfo.roomType = TUIRoomType.livingRoom;roomInfo.seatMode = TUISeatMode.applyToTake;final startLiveStreamResult = await controller.startLiveStream(roomInfo);final startMicrophoneResult = await controller.startMicrophone();
val livecoreView = LiveCoreView(this)
LiveCoreView liveCoreView = new LiveCoreView(this);
import LiveStreamCorelet liveCoreView = LiveCoreView()
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final controller =LiveCoreController();LiveCoreWidget(controller: controller);
livecoreView.joinLiveStream("roomId_123456", null)
livecoreView.joinLiveStream("roomId_123456", null);
import LiveStreamCoreliveCoreView.joinLiveStream(roomId: "roomId_123456") { roomInfo in} onError: { code, message in}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';var result = await controller.joinLiveStream('replace with your roomId');
Single-Person Co-Broadcasting | Multi-Person Co-Anchoring |
![]() | ![]() |
val userId = "anchorUserId"; // Change to room owner's UserId, defaults to room owner UserId when input empty stringval timeout = 60;liveCoreView.requestIntraRoomConnection(userId, 10, null)
String userId = "anchorUserId"; // Change to room owner's UserId, defaults to room owner UserId when input empty stringint timeout = 60;liveCoreView.requestIntraRoomConnection(userId, timeout, true, null);
let timeout = 60let userId = "anchorUserId" // Change to room owner's UserId, defaults to room owner UserId when input empty stringliveCoreView.requestIntraRoomConnection(userId: userId, timeOut: timeOut, openCamera: true) {} onError: { code, message in}
NSInteger timeout = 60;NSString userId = "anchorUserId" // Change to room owner's UserId, defaults to room owner UserId when input empty string[liveCoreView requestIntraRoomConnection:""timeOut:timeoutonSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final timeout = 60;final userId = 'anchorUserId'; // Change to room owner's UserId, defaults to room owner UserId when input empty stringfinal openCamera = true;final result = await controller.requestIntraRoomConnection(userId,timeout,openCamera);
override fun onUserConnectionRequest(inviterUser: UserInfo) {Log.i(TAG, "Received audience connection request: ${inviterUser.userId}")}
@Overridepublic void onUserConnectionRequest(LiveStreamDefine.LiveUser inviterUser) {Log.i(TAG, "Received audience connection request: " + inviterUser.userId);}
func onUserConnectionRequest(inviterUser: TUIUserInfo) {print("Received audience connection request: \\(inviterUser.userId)")}
- (void)onUserConnectionRequest:(TUIUserInfo *)inviterUser {NSLog(@"Received audience connection request: %@", hostUser.userId);}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller =LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.onUserConnectionRequest = (inviterUser) {debugPrint('Received audience connection request: ${inviterUser.userId}');};}}
// Host agrees to connect micliveCoreView.respondIntraRoomConnection(audienceBUserId, true, null)
// Host agrees to connect micliveCoreView.respondIntraRoomConnection(userId, true, null);// Host rejects mic connectionliveCoreView.respondIntraRoomConnection(userId, false, null);
// Host agrees to connect micliveCoreView.respondIntraRoomConnection(userId: audienceBUserId, isAccepted: true) {} onError: { code, message in}
// Host agrees to connect mic[liveCoreView respondIntraRoomConnection:audienceBUserIdisAccepted:YESonSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';// Host agrees to connect micfinal result = await controller.respondIntraRoomConnection('audienceBUserId',true);
override fun onUserConnectionAccepted(inviterUser: UserInfo) {Log.i(TAG, "Audience agreed to connection: ${inviterUser.userId}")}
@Overridepublic void onUserConnectionAccepted(LiveStreamDefine.LiveUser liveUser) {Log.i(TAG, "Audience agreed to connection: " + liveUser.userId);}@Overridepublic void onUserConnectionRejected(LiveStreamDefine.LiveUser liveUser) {Log.i(TAG, "Audience rejected connection: " + liveUser.userId);}
func onUserConnectionAccepted(userId: String) {print("Audience agreed to connection: \\(userId)")}
- (void)onUserConnectionAccepted:(NSString *)userId {NSLog(@"Audience agreed to connection: %@", userId);}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.onUserConnectionAccepted = (user) {debugPrint('Broadcaster agrees to connecting line: ${user.userId}');};}}
override fun onConnectedUsersUpdated(inviterUser: UserInfo) {Log.i(TAG, "Changes in the list of mic-connected users")}
@Overridepublic void onConnectedUsersUpdated(List<UserInfo> userList, List<UserInfo> joinList, List<UserInfo> leaveList) {Log.i(TAG, "Changes in the list of mic-connected users")}
func onConnectedUsersUpdated(userList: [TUIUserInfo], joinList: [TUIUserInfo], leaveList: [TUIUserInfo]) {print("Changes in the list of mic-connected users")}
- (void)onConnectedUsersUpdated:(NSArray<TUIUserInfo *> *)userListjoinList:(NSArray<TUIUserInfo *> *)joinListleaveList:(NSArray<TUIUserInfo *> *)leaveList {NSLog(@"Changes in the list of mic-connected users"); // Here you can handle userList, joinList and leaveList if necessary}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.OnConnectedUsersUpdated = (userList, joinList, leaveList) {debugPrint('Changes in the list of mic-connected users');};}}
val userId = "audienceBUserId"liveCoreView.disconnectUser(userId, null)
String userId = "audienceUserId";liveCoreView.disconnectUser(userId, null);
let userId = "audienceBUserId"liveCoreView.disconnectUser(userId: userId) {} onError: { code, message in}
NSString *userId = @"audienceBUserId";[liveCoreView disconnectUser:userIdonSuccess:^{} onError:^(NSInteger code, NSString * _Nonnull message) {}];
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';final userId = 'audienceBUserId';final result = await controller.disconnectUser(userId);
override fun onUserConnectionTerminated(inviterUser: UserInfo) {Log.i(TAG, "Anchor closed connecting line")}
@Overridepublic void onUserConnectionTerminated() {Log.i(TAG, "Anchor closed connecting line")}
func onUserConnectionTerminated() {print("Anchor closed connecting line")}
- (void)onUserConnectionTerminated {NSLog(@"Anchor closed connecting line");}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.onUserConnectionTerminated = (user) {debugPrint('Anchor closed connecting line') ;};}}
liveCoreView.terminateIntraRoomConnection()
liveCoreView.terminateIntraRoomConnection();
liveCoreView.terminateIntraRoomConnection()
[liveCoreView terminateIntraRoomConnection]
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final result = await controller.terminateIntraRoomConnection();
override fun onUserConnectionExited(inviterUser: LiveStreamDefine.LiveUser) {Log.i(TAG, "Audience exit connection")}
@Overridepublic void onUserConnectionExited(UserInfo liveUser) {Log.i(TAG, "Audience exit connection: ${liveUser.userId}");}
func onUserConnectionExited(userInfo: TUIUserInfo) {print("Audience exit connection")}
- (void)onUserConnectionExited:(TUIUserInfo *)userInfo {NSLog(@"Audience exited connection");}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.onUserConnectionExited = (user) {debugPrint('Audience exited connection');};}}
Dual-Anchor Connection | Multi-Anchor Connection |
![]() | ![]() |
requestCrossRoomConnection, inputting the room id of Anchor B in the parameter roomId.val roomId = "anchorBRoomId"mLiveViewList.requestCrossRoomConnection(roomId, 10, null)
String roomId = "anchorBRoomId";mLiveViewList.requestCrossRoomConnection(roomId, 10, null);
let roomId = "anchorRoomId"liveCoreView.requestCrossRoomConnection(roomId: roomId, timeOut: 60) {} onError: { code, message in}
NSString *roomId = @"anchorRoomId";[liveCoreView requestCrossRoomConnection:roomIdtimeOut:60onSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final roomId = 'anchorBRoomId';final result = await controller.requestCrossRoomConnection(roomId);
onCrossRoomConnectionAccepted.onCrossRoomConnectionRequest.override fun onCrossRoomConnectionRequest(inviterUser: UserInfo) {Log.i(TAG, "Received Anchor A room request: ${inviterUser.userId}")}
@Overridepublic void onCrossRoomConnectionRequest(LiveStreamDefine.RoomInfo roomInfo) {Log.i(TAG, "Received Anchor A room request: " + roomInfo.roomId);}
func onCrossRoomConnectionRequest(hostUser: TUIConnectionUser) {print("Received Anchor A room request: \\(hostUser.userId)")}
- (void)onCrossRoomConnectionRequest:(TUIConnectionUser *)hostUser {NSLog(@"Received Anchor A connecting line room request: %@", hostUser.userId);}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.onCrossRoomConnectionRequest = (user) {debugPrint('Received Anchor A connecting line room request: ${user.userId}');};}}
respondToCrossRoomConnection.'}liveCoreView.respondToCrossRoomConnection(roomId, true, null)
// Grant connection requestliveCoreView.respondToCrossRoomConnection(roomId, true, null);
liveCoreView.respondToCrossRoomConnection(roomId: roomId, isAccepted: true) {} onError: { code, message in}
[liveCoreView respondToCrossRoomConnection:roomIdisAccepted:trueonSuccess:^(void) {} onError:^(NSInteger code, NSString * _Nonnull message) {}];
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final roomId = 'anchorBRoomId';final isAccpeted = true;final result = await controller.respondToCrossRoomConnection(roomId, isAccpeted);
onConnectedRoomsUpdated callback, notifying that the connection list has changed. override fun onConnectedRoomsUpdated(inviterUser: UserInfo) {Log.i(TAG, "Anchor connection room list update")}
@Overridepublic void onConnectedRoomsUpdated(List<LiveStreamDefine.RoomInfo> roomList) {Log.i(TAG, "Anchor connection room list update")}
func onConnectedRoomsUpdated(hostUserList: [TUIConnectionUser]) {print("Anchor connection room list update")}
- (void)onConnectedRoomsUpdated:(NSArray<TUIConnectionUser *> *)hostUserList {NSLog(@"Anchor connection room list refresh");}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends ConnectionObserver {ExampleObserver() {super.onConnectedRoomsUpdated= (user) {debugPrint('Anchor connection room list refresh') ;};}}
terminateIntraRoomConnection to exit connection.public void disconnect(TUIRoomDefine.ActionCallback callback) {mTUILiveConnectionManager.disconnect(callback);}
liveCoreView.terminateIntraRoomConnection()
liveCoreView.terminateCrossRoomConnection()
[liveCoreView terminateCrossRoomConnection];
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';final result = await controller.terminateIntraRoomConnection();
Anchor Connection - Grid Layout | Anchor Connection - Floating Window Layout | Anchor Connection - Custom Layout |
![]() | ![]() |
![]() |
// Set grid layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.GRID_LAYOUT, "")// Set floating window layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FLOAT_LAYOUT, "")// Set custom layoutvar layoutJson = ""mLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FREE_LAYOUT, layoutJson)
// Set grid layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.GRID_LAYOUT, "");// Set floating window layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FLOAT_LAYOUT, "");// Set custom layoutString layoutJson = "";mLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FREE_LAYOUT, layoutJson);
import LiveStreamCore// Set grid layoutliveCoreView.setLayoutMode(layoutMode: .gridLayout)// Set floating window layoutliveCoreView.setLayoutMode(layoutMode: .floatLayout)// Set custom layoutlet layoutJson = ""liveCoreView.setLayoutMode(layoutMode: .freeLayout, layoutJson: layoutJson)
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';// Set grid layoutcontroller.setLayoutMode(LayoutMode.gridLayout);// Set floating window layoutcontroller.setLayoutMode(LayoutMode.floatLayout);// Set custom layoutfinal layoutJson = '';controller.setLayoutMode(LayoutMode.freeLayout, layoutJson);
{"1": { // number of video views"backgroundColor": "#000000", // Background color of the canvas, use hexadecimal format"viewInfoList": [{ // layout information and background color of each video view"x": 0, // horizontal offset ratio to screen width, value ranges from 0 to 1"y": 0, // vertical offset ratio to screen width, value ranges from 0 to 1"width": 1, // width ratio of video view to screen width, value ranges from 0 to 1"height": -1, // height ratio of video view to screen width, value ranges from 0 to 1 or -1; -1 means the view height is identical to the screen height"zOrder": 0, // Z-order of video view, the larger the value, the view aligns top"backgroundColor": "#000000" // Background color of video view in RGB hexadecimal format}]}}
Dual-Anchor PK | Multi-Anchor PK |
![]() | ![]() |
LiveCoreView.BattleObserver object set by LiveCoreView.requestBattle.val BATTLE_DURATION = 30val battleConfig = BattleConfig()battleConfig.duration = BATTLE_DURATIONbattleConfig.needResponse = truebattleConfig.extensionInfo = ""val list: MutableList<String> = ArrayList()list.add("anchorBUserId")val BATTLE_REQUEST_TIMEOUT = 10liveCoreView.requestBattle(battleConfig, list, BATTLE_REQUEST_TIMEOUT,object : LiveCoreViewDefine.BattleRequestCallback {override fun onSuccess(battleId: String, requestedUserIdList: List<String>) {}override fun onError(error: TUICommonDefine.Error, message: String) {}})
final int BATTLE_DURATION = 30;TUILiveBattleManager.BattleConfig battleConfig = new TUILiveBattleManager.BattleConfig();battleConfig.duration = BATTLE_DURATION;battleConfig.needResponse = true;battleConfig.extensionInfo = "";List<String> list = new ArrayList<>();list.add("anchorBUserId");final int BATTLE_REQUEST_TIMEOUT = 10;liveCoreView.requestBattle(battleConfig, list, BATTLE_REQUEST_TIMEOUT,new LiveCoreViewDefine.BattleRequestCallback() {@Overridepublic void onSuccess(String battleId, List<String> requestedUserIdList) {}@Overridepublic void onError(TUICommonDefine.Error error, String message) {}});
let roomId = "anchorRoomId"let config = TUIBattleConfig()config.duration = battleDurationconfig.needResponse = trueconfig.extensionInfo = ""let userIdList: [String] = []let timeout: TimeInterval = 10liveCoreView.requestBattle(config: config, userIdList: userIdList, timeout: timeout) {[weak self] (battleId, battleUserList) in} onError: { _, _ in}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';final roomId = 'anchorRoomId';final config = TUIBattleConfig();config.duration = 30;final result = await controller.requestBattle(config, [roomId], 10);
onBattleRequestAccept.onBattleRequestReceived.override fun onBattleRequestReceived(battleId: String, inviterUser: BattleUser, invitee: BattleUser) {Log.i(TAG, "Received Anchor A's battle request: $battleId")}
@Overridepublic void onBattleRequestReceived(String battleId, BattleUser inviter, BattleUser invitee) {Log.i(TAG, "Received Anchor A's battle request: " + battleId);}
extension ViewContrller: BattleObserver { //replace with your actual class namefunc onBattleRequestReceived(battleId: String, inviter: TUIBattleUser, invitee: TUIBattleUser) {}}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends BattleObserver {ExampleObserver() {super.onBattleRequestReceived= (battleId, inviter, invitee) {debugPrint('Received Anchor A battle request');};}}
respondToBattle.// Grant battle requestval battleId = "battleId"liveCoreView.respondToBattle(battleId, true, null)
// Grant battle requestString battleId = "battleId";liveCoreView.respondToBattle(battleId, true, null);
liveCoreView.respondToBattle(battleId: manager.battleState.battleId, isAccepted: false, onSuccess: { [weak self] in}, onError: { _, _ in})
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Grant battle requestfinal battleId = '';final result = await controller.respondToBattle(battleId, true);
onBattleStarted and the start notification. override fun onBattleStarted(battleInfo: BattleInfo) {Log.i(TAG, "PK start callback")}
@Overridepublic void onBattleStarted(BattleInfo battleInfo) {Log.i(TAG, "Anchor connection room list update")}
extension ViewContrller: BattleObserver { //replace with your actual class namefunc onBattleStarted(battleInfo: TUIBattleInfo)) {}}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';// Create a listener Observer instancefinal controller = LiveCoreController();final exampleObserver = ExampleObserver();// add observercontroller.addObserver(exampleObserver);class ExampleObserver extends BattleObserver {ExampleObserver() {super.onBattleStarted = (battleInfo) {debugPrint('PK start callback');};}}
onBattleEnded callback.terminateBattle and will exit PK, while Anchor A receives onUserExitBattle.mLiveCoreView.terminateBattle(battleId, null)
mLiveCoreView.terminateBattle(battleId, null);
liveCoreView.terminateBattle(battleId: manager.battleState.battleId) {} onError: { _, _ in}
import 'package:live_stream_core/live_core_widget/live_core_widget.dart';import 'package:rtc_room_engine/rtc_room_engine.dart';final battleId = '';final result = await controller.terminateBattle(battleId);
Feedback