• 製品
  • 価格
  • リソース
  • サポート
このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

LiveCoreWidget

API Introduction

LiveCoreWidget is a basic control we developed for the video live streaming UIKit. This core control provides various APIs, including preview before broadcasting, start video live streaming, stop video live streaming, live streaming room connection with audience, and cross-room connection with other anchors.

API Overview

API
Description
Create a LiveCoreController object
Create a LiveCoreWidget object.
Start camera capture and display the screen on LiveCoreView.
Open local microphone
Pause publishing local audio stream
Resume publishing suspended local audio stream
Turn the local camera off
Close local microphone
Anchor create live room and start streaming
Anchor stop streaming and destroy live room
Audience joins a certain live streaming room
Audience leaves a certain live streaming room
Audience requests to connect with the anchor
Cancel the request to connect with the anchor
Anchor responds to the audience's request for connection
Anchor disconnects the audience
Audience disconnects from the anchor
Anchor requests cross-room connection with another anchor
Cancel the request for cross-room connection with another anchor
Anchor responds to the connection request
Anchor disconnects
Register a callback for connection event
Unregister a callback for connection event
Initiate a battle request
Cancel a battle request
Respond to battle request
End PK
Register a callback for PK event
Unregister a callback for PK event
Set the layout mode for the connected host's video image
Start room video stream preview.
Stop room video stream preview.

API Details

LiveCoreController

Create a LiveCoreController object instance.
LiveCoreController()
Return value: LiveCoreController

LiveCoreWidget

Create a LiveCoreWidget object instance.
LiveCoreWidget(
{super.key,
required this.controller,
this.videoWidgetBuilder});
Parameters:
Parameter
Type
Meaning
key
Key?
Flutter controls how to replace an old widget with a new one using parameters
controller
LiveCoreWidget controller, responsible for providing live streaming scenario APIs
videoWidgetBuilder
Custom view widget constructor
Return value: LiveCoreWidget

startCamera

Start camera capture and display the screen on LiveCoreWidget.
Future<TUIActionCallback> startCamera(bool useFrontCamera)
Parameters:
Parameter
Type
Meaning
useFrontCamera
bool
true: use the front camera; false: use the rear-facing camera
Return Value: Future<TUIActionCallback>

startMicrophone

Open local microphone.
Future<TUIActionCallback> startMicrophone()
Return Value: Future<TUIActionCallback>

muteMicrophone

Pause publishing local audio stream.
void muteMicrophone()
Return Value: void

unmuteMicrophone

Resume publishing suspended local audio stream.
Future<TUIActionCallback> unmuteMicrophone()
Return Value: void

stopCamera

Turn the local camera off.
void stopCamera()
Return Value: void

stopMicrophone

Close local microphone.
void stopMicrophone()
Return Value: void

startLiveStream

Anchor create live room and start streaming.
Future<TUIValueCallBack<TUIRoomInfo>> startLiveStream(TUIRoomInfo roomInfo)
Parameters:
Parameter
Type
Meaning
roomInfo
Create live streaming room info
Return Value: Future<TUIValueCallBack<TUIRoomInfo>>

stopLiveStream

Anchor stop streaming and destroy live room.
Future<TUIActionCallback> stopLiveStream()
Return Value: Future<TUIActionCallback>

joinLiveStream

Audience joins a certain live streaming room.
Future<TUIValueCallBack<TUIRoomInfo>> joinLiveStream(String roomId)
Parameters:
Parameter
Type
Meaning
roomId
String
Live streaming room ID
Return Value: Future<TUIValueCallBack<TUIRoomInfo>>

leaveLiveStream

Audience leaves a certain live streaming room.
Future<TUIActionCallback> leaveLiveStream()
Return Value: Future<TUIActionCallback>

requestIntraRoomConnection

Audience requests to connect with the anchor.
Future<TUIActionCallback> requestIntraRoomConnection(
String userId,
int timeout,
bool openCamera)
Parameters:
Parameter
Type
Meaning
userId
String
User ID. If the input is the anchor ID, it signifies the audience requests to connect with the anchor (defaults to the anchor's user ID if the input is an empty string). For other user IDs, it represents the anchor inviting the corresponding user to connect.
timeout
int
Request timeout duration, in seconds.
openCamera
bool
Whether to open the camera upon success. true: video communication, false: audio mic connection.
Return Value: Future<TUIActionCallback>

cancelIntraRoomConnection

Cancel the request to connect with the anchor.
Future<TUIActionCallback> cancelIntraRoomConnection(String userId)
Parameters:
Parameter
Type
Meaning
userId
String
The user ID for canceling mic connection. If the input is the anchor ID, it signifies the audience cancels the request to connect with the anchor (an empty string defaults to the anchor's user ID). For other user IDs, it signifies the anchor cancels the invitation to connect with the corresponding user.
Return Value: Future<TUIActionCallback>

respondIntraRoomConnection

The anchor responds to the audience's request for connection.
Future<TUIActionCallback> respondIntraRoomConnection(String userId, bool isAccepted)
Parameters:
Parameter
Type
Meaning
userId
String
Anchor response to the audience user ID in live streaming room connection. If the anchor's user ID is imported, it signifies the audience response to the anchor's invitation (defaults to the anchor's user ID when an empty string is input).
isAccepted
bool
Whether to accept the mic connection request. true: grant the request, false: reject the request.
Return Value: Future<TUIActionCallback>

disconnectUser

Anchor disconnects the audience.
Future<TUIActionCallback> disconnectUser(String userId)
Parameters:
Parameter
Type
Meaning
userId
String
Anchor needs to disconnect the user ID
Return Value: Future<TUIActionCallback>

terminateIntraRoomConnection

Audience disconnects from the anchor.
Future<TUIActionCallback> terminateIntraRoomConnection()
Return Value: Future<TUIActionCallback>

requestCrossRoomConnection

Anchor requests cross-room connection with another anchor.
Future<TUIValueCallBack<TUIConnectionCode?>> requestCrossRoomConnection(String roomId, int timeout)
Parameters:
Parameter
Type
Meaning
roomId
String
Room ID for cross-room connection request.
timeout
int
Request timeout duration, in seconds.
Return Value: Future<TUIValueCallBack<TUIConnectionCode?>>

cancelCrossRoomConnection

Cancel the request for cross-room connection with another anchor.
Future<TUIActionCallback> cancelCrossRoomConnection(String roomId)
Parameters:
Parameter
Type
Meaning
roomId
String
Room ID for canceling the connection
Return Value: Future<TUIActionCallback>

respondToCrossRoomConnection

The anchor responds to the connection request.
Future<TUIActionCallback> respondToCrossRoomConnection(String roomId, bool isAccepted)
Parameters:
Parameter
Type
Meaning
roomId
String
Room ID for connection response
isAccepted
bool
Whether to agree to connection. true: agree to connection, false: reject connection.
Return Value: Future<TUIActionCallback>

terminateCrossRoomConnection

Anchor disconnects.
Future<TUIActionCallback> terminateCrossRoomConnection()
Return Value: Future<TUIActionCallback>

registerConnectionObserver

Register a callback for connection event.
void registerConnectionObserver(ConnectionObserver observer)
Parameters:
Parameter
Type
Meaning
observer
callback object for connection event
Return Value: void

unregisterConnectionObserver

Unregister a callback for connection event.
void unregisterConnectionObserver(ConnectionObserver observer)
Parameters:
Parameter
Type
Meaning
observer
callback object for connection event
Return Value: void

requestBattle

Initiate a battle request.
Future<TUIValueCallBack<BattleRequestCallback>> requestBattle(
TUIBattleConfig config,
List<String> userIdList,
int timeout)
Parameters:
Parameter
Type
Meaning
config
PK parameter configuration, including PK duration and extended information. PK currently supports a maximum duration of 300 seconds.
userIdList
List<String>
Invite the room owner's userId for PK
timeout
int
PK request timeout duration, in seconds

cancelBattle

Cancel the battle request.
Future<TUIActionCallback> cancelBattle(String battleId, List<String> userIdList)
Parameters:
Parameter
Type
Meaning
battleId
String
PK unique representation
userIdList
List<String>
Cancel the room owner's userId invitation for PK
Return Value: Future<TUIActionCallback>

respondToBattle

Respond to a battle request.
Future<TUIActionCallback> respondToBattle(String battleId, bool isAccepted)
Parameters:
Parameter
Type
Meaning
battleId
String
PK unique representation
isAccepted
bool
Grant PK invitation
Return Value: Future<TUIActionCallback>

terminateBattle

End PK.
Future<TUIActionCallback> terminateBattle(String battleId)
Parameters:
Parameter
Type
Meaning
battleId
String
PK unique representation
Return Value: Future<TUIActionCallback>

registerBattleObserver

Register a callback for PK event.
void registerBattleObserver(BattleObserver observer)
Parameters:
Parameter
Type
Meaning
observer
callback object for PK event
Return Value: void

unregisterBattleObserver

Unregister a callback for connection event.
void unregisterBattleObserver(BattleObserver observer)
Parameters:
Parameter
Type
Meaning
observer
callback object for PK event
Return Value: void

setLayoutMode

Set the layout mode for the connected host's video image.
void setLayoutMode(
LayoutMode layoutMode,
bool showEmptySeat,
String? layoutJson)
Parameters:
Parameter
Type
Meaning
layoutMode
LayoutMode
The layout mode when connecting supports grid layout, floating window layout, and custom layout.
showEmptySeat
bool
Whether to display empty mic slots (unavailable)
layoutJson
String?
The json string for the layout. For specific usage, see Set Custom Layout.
Return Value:void

startPreloadVideoStream

Start room video stream preview.
void startPreloadVideoStream(
String roomId,
bool isMuteAudio,
int viewId,
TUIPlayCallback? playCallback)
Parameters:
Parameter
Type
Meaning
roomId
String
Preview the room number for video streaming
isMuteAudio
bool
Whether to mute the preview video str
viewId
int
View ID returned when creating a VideoVie
playCallback
TUIPlayCallback?
Preview video stream callback function
Return Value:void

stopPreloadVideoStream

Stop room video stream preview.
void stopPreloadVideoStream(String roomId)
Parameters:
Parameter
Type
Meaning
roomId
String
Stop previewing the video stream of the room numbe
Return Value:void

Type Definition

Type
Description
The layout mode when connecting
Connected user data
PK user view location data
Battle request result callback
View widget constructor for live co-streaming
View widget constructor for connecting
View widget constructor for host video during PK
Full-screen view widget constructor for PK
Custom view widget constructor
Callback for changes in the list of users in mic-connection
Callback for received mic connection request
Callback for received mic connection cancellation request
Callback for approved mic connection request
Callback for rejected mic connection request
Callback for mic connection request timeout
Callback for anchor disconnecting the audience mic connection
Callback for audience proactive disconnection of the connecting line
Callback for changes in the cross-room connection room list
Callback for received cross-room connection request
Callback for received cancellation of cross-room connection request
Callback for received consent to cross-room connection
Callback for received deny of cross-room connection
Callback for received cross-room connection timeout
Callback for received cross-room disconnection
Callback for received PK start
Callback for received PK end
Callback for received participant join PK end
Callback for received participant leave PK end
Callback for received PK score change
Callback for received battle request
Received cancellation of battle request
Callback for received PK request timeout
Received callback for battle request approval
Callback for received reject PK request
Callback for received room termination

LayoutMode

Layout mode of the microphone position list
Enumeration Value
Description
focus
Focus layout
grid
grid layout
vertical
vertical layout
free
custom layout

CoHostUser

Connected user data
Attribute
Type
Description
connectionUser
Connected user personal information
hasAudioStream
bool
Connected user audio stream information
hasVideoStream
bool
Connected user video stream information

BattleUserWidgetModel

Attribute
Type
Description
battleUser
PK user personal information
rect
Rect
PK user view location info

BattleRequestCallback

Battle request result callback
Attribute
Type
Description
battleId
String
PK unique identifier
requestedUserList
PK invite list of users
onError
void Function(TUIError error, String message)
PK invite error result

CoGuestWidgetBuilder

View widget widget constructor for live co-streaming
typedef CoGuestWidgetBuilder = Widget Function(
BuildContext context,
TUIUserInfo userInfo);
Parameters:
Parameter
Type
Description
context
BuildContext
Context
userInfo
Mic-connecting user information

CoHostWidgetBuilder

View widget widget constructor for live co-streaming
typedef CoHostWidgetBuilder = Widget Function(
BuildContext context,
CoHostUser userInfo);
Parameters:
Parameter
Type
Description
context
BuildContext
Context
userInfo
Connected user data

BattleWidgetBuilder

View widget constructor for host video during PK
typedef BattleWidgetBuilder = Widget Function(
BuildContext context,
TUIBattleUser userInfo);
Parameters:
Parameter
Type
Description
context
BuildContext
Context
userInfo
PK user information

BattleContainerWidgetBuilder

Full-screen view widget widget constructor for PK
typedef BattleContainerWidgetBuilder = Widget Function(
BuildContext context,
List<BattleUserWidgetModel> battleModels);
Parameters:
Parameter
Type
Description
context
BuildContext
Context
battleModels
PK user view position layout info

VideoWidgetBuilder

Custom view widget constructor
typedef OnSeatWidgetTap = void Function(TUISeatInfo seatInfo);
Parameters:
Parameter
Type
Description
seatInfo
seat information

OnConnectedUsersUpdated

Callback for changes in the list of users in mic-connection
typedef OnConnectedUsersUpdated = void Function(
List<TUIUserInfo> userList,
List<TUIUserInfo> joinList,
List<TUIUserInfo> leaveList);
Parameters:
Parameter
Type
Description
userList
co-broadcasting user list
joinList
list of users who joined co-broadcasting
leaveList
List of users who left co-broadcasting

OnUserConnectionRequest

Callback for received mic connection request
typedef OnUserConnectionRequest = void Function(TUIUserInfo inviterUser);
Parameters:
Parameter
Type
Description
inviterUser
Mic-connecting user information

OnUserConnectionCancelled

Callback for received mic connection cancellation request
typedef OnUserConnectionCancelled = void Function(TUIUserInfo inviterUser);
Parameters:
Parameter
Type
Description
inviterUser
Mic-connecting user information

OnUserConnectionAccepted

Callback for approved mic connection request
typedef OnUserConnectionAccepted = void Function(TUIUserInfo userInfo);
Parameters:
Parameter
Type
Description
userInfo
Mic-connecting user information

OnUserConnectionRejected

Callback for rejected mic connection request
typedef OnUserConnectionRejected = void Function(TUIUserInfo userInfo);
Parameters:
Parameter
Type
Description
userInfo
Mic-connecting user information

OnUserConnectionTimeout

Callback for mic connection request timeout
typedef OnUserConnectionTimeout = void Function(TUIUserInfo userInfo);
Parameters:
Parameter
Type
Description
userInfo
Mic-connecting user information

OnUserConnectionTerminated

Callback for anchor disconnecting the audience mic connection
typedef OnUserConnectionRejected = void Function();

OnUserConnectionExited

Callback for audience proactive disconnection of the connecting line
typedef OnUserConnectionExited = void Function(TUIUserInfo userInfo);
Parameters:
Parameter
Type
Description
userInfo
Mic-connecting user information

OnConnectedRoomsUpdated

Callback for changes in the cross-room connection room list
typedef OnConnectedRoomsUpdated = void Function(List<TUIConnectionUser> hostUserList);
Parameters:
Parameter
Type
Description
hostUserList
Connected user list

OnCrossRoomConnectionRequest

Callback for received cross-room connection request
typedef OnCrossRoomConnectionRequest = void Function(TUIConnectionUser hostUser);
Parameters:
Parameter
Type
Description
hostUser
Connected user

OnCrossRoomConnectionCancelled

Callback for received cancellation of cross-room connection request
typedef OnCrossRoomConnectionCancelled = void Function(TUIConnectionUser hostUser);
Parameters:
Parameter
Type
Description
hostUser
Connected user

OnCrossRoomConnectionAccepted

Callback for received consent to cross-room connection
typedef OnCrossRoomConnectionAccepted = void Function(TUIConnectionUser hostUser);
Parameters:
Parameter
Type
Description
hostUser
Connected user

OnCrossRoomConnectionRejected

Callback for received deny of cross-room connection
typedef OnCrossRoomConnectionRejected = void Function(TUIConnectionUser hostUser);
Parameters:
Parameter
Type
Description
hostUser
Connected user

OnCrossRoomConnectionTimeout

Callback for received cross-room connection timeout
typedef OnCrossRoomConnectionTimeout = void Function(
TUIConnectionUser inviter,
TUIConnectionUser invitee);
Parameters:
Parameter
Type
Description
inviter
Connecting line request initiator
invitee
Connection invitation recipient

OnCrossRoomConnectionExited

Callback for received cross-room disconnection
typedef OnCrossRoomConnectionExited = void Function(TUIConnectionUser hostUser);
Parameters:
Parameter
Type
Description
hostUser
Connected user

OnBattleStarted

Callback for received PK start
typedef OnBattleStarted = void Function(TUIBattleInfo battleInfo);
Parameters:
Parameter
Type
Description
battleInfo
PK info

OnBattleEnded

Callback for received PK end
typedef OnBattleEnded = void Function(TUIBattleInfo battleInfo);
Parameters:
Parameter
Type
Description
battleInfo
PK info

OnUserJoinBattle

Callback for received participant join PK end
typedef OnUserJoinBattle = void Function(
String battleId,
TUIBattleUser battleUser);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
battleUser
PK user

OnUserExitBattle

Callback for received participant leave PK end
typedef OnUserExitBattle = void Function(
String battleId,
TUIBattleUser battleUser);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
battleUser
PK user

OnBattleScoreChanged

Callback for received PK score change
typedef OnBattleScoreChanged = void Function(
String battleId,
List<TUIBattleUser> battleUserList);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
battleUserList
PK list of users

OnBattleRequestReceived

Callback for received battle request
typedef OnBattleRequestReceived = void Function(
String battleId,
TUIBattleUser inviter,
TUIBattleUser invitee);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
inviter
PK invite initiator
invitee
PK invitee

OnBattleRequestCancelled

Received cancellation of battle request
typedef OnBattleRequestCancelled = void Function(
String battleId,
TUIBattleUser inviter,
TUIBattleUser invitee);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
inviter
PK invite initiator
invitee
PK invitee

OnBattleRequestTimeout

Callback for received PK request timeout
typedef OnBattleRequestTimeout = void Function(
String battleId,
TUIBattleUser inviter,
TUIBattleUser invitee);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
inviter
PK invite initiator
invitee
PK invitee

OnBattleRequestAccept

Received callback for battle request approval
typedef OnBattleRequestAccept = void Function(
String battleId,
TUIBattleUser inviter,
TUIBattleUser invitee);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
inviter
PK invite initiator
invitee
PK invitee

OnBattleRequestReject

Callback for received reject PK request
typedef OnBattleRequestReject = void Function(
String battleId,
TUIBattleUser inviter,
TUIBattleUser invitee);
Parameters:
Parameter
Type
Description
battleId
String
PK unique identifier
inviter
PK invite initiator
invitee
PK invitee

OnRoomDismissed

Callback for received room termination
typedef OnRoomDismissed = void Function(String roomId);
Parameters:
Parameter
Type
Description
roomId
String
Room Id

ConnectionObserver Event Definition

Event list
Type
Description
onConnectedUsersUpdated
Callback for changes in the list of users in mic-connection
onUserConnectionRequest
Callback for received mic connection request
onUserConnectionCancelled
Callback for received mic connection cancellation request
onUserConnectionAccepted
Callback for approved mic connection request
onUserConnectionRejected
Callback for rejected mic connection request
onUserConnectionTimeout
Callback for mic connection request timeout
onUserConnectionTerminated
Callback for anchor disconnecting the audience mic connection
onUserConnectionExited
Callback for audience proactive disconnection of the connecting line
onConnectedRoomsUpdated
Callback for changes in the cross-room connection room list
onCrossRoomConnectionRequest
Callback for received cross-room connection request
onCrossRoomConnectionCancelled
Callback for received cancellation of cross-room connection request
onCrossRoomConnectionAccepted
Callback for received consent to cross-room connection
onCrossRoomConnectionRejected
Callback for received deny of cross-room connection
onCrossRoomConnectionTimeout
Callback for received cross-room connection timeout
onCrossRoomConnectionExited
Callback for received cross-room disconnection
onRoomDismissed
Callback for received room termination

BattleEvent Definition for BattleObser>

Event list
Type
Description
onBattleStarted
Callback for received PK start
onBattleEnded
Callback for received PK end
onUserJoinBattle
Callback for received participant join PK end
onUserExitBattle
Callback for received participant leave PK end
onBattleScoreChanged
Callback for received PK score change
onBattleRequestReceived
Callback for received battle request
onBattleRequestCancelled
Received cancellation of battle request
onBattleRequestTimeout
Callback for received PK request timeout
onBattleRequestAccept
Received callback for battle request approval
onBattleRequestReject
Callback for received reject PK request