SeatGridWidget

API Introduction

SeatGridWidget is a basic control we developed for the voice chat room UIKit. This core control provides various APIs such as enabling/disabling the voice chat room, managing microphone positions in the live streaming room, including applying for microphone mode, inviting speakers, moving microphone positions, and kicking someone off the mic.

API Overview

API
Description
Create a SeatGridController object
Create a SeatGridWidget object
Open the local microphone
Close the local microphone
Pause publishing local audio stream
Resume publishing local audio stream
Anchor creates a live room and starts streaming.
Anchor stops streaming and destroys the live room.
Audience joins an anchor's live streaming room.
Audience leaves an anchor's live streaming room.
Update the seat mode of the room.
Anchor responds to microphone application / Audience responds to microphone invitation
Anchor cancels microphone invitation / Audience cancels microphone application
takeSeat
Become a speaker.
Move the seat.
leaveSeat
Leave the seat.
Anchor invites users to speak.
Anchor removes a user from the seat.
lockSeat
Anchor locks the seat (including position lock, audio status lock and video status lock)
Anchor sets the layout mode of the seat list.
Set event callback
Remove event callback

API Details

SeatGridController

Create an object instance of SeatGridController. SeatGridController is responsible for providing APIs for the voice chat room scenario.
SeatGridController()
Return Value: SeatGridController

SeatGridWidget

Create an instance of SeatGridWidget. SeatGridWidget is responsible for rendering the seat UI.
SeatGridWidget(
{super.key,
required this.controller,
this.seatWidgetBuilder,
this.onSeatWidgetTap});
Parameters:
Parameter
Type
Meaning
key
Key?
How does Flutter control replacing the parameters of an old widget with a new widget
controller
Controller of SeatGridWidget, responsible for providing APIs in the live voice room scenario
seatWidgetBuilder
Constructor of the custom seat widget
onSeatWidgetTap
Callback for seat click event
Return Value: SeatGridWidget

startMicrophone

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

stopMicrophone

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

muteMicrophone

Pause publishing local audio stream.
Future<TUIActionCallback> muteMicrophone()
Return Value: Future<TUIActionCallback>

unmuteMicrophone

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

startVoiceRoom

Anchor creates a live room and starts streaming.
Future<TUIValueCallBack<TUIRoomInfo>> startVoiceRoom(TUIRoomInfo roomInfo)
Parameters:
Parameter
Type
Meaning
roomInfo
Information of creating a live streaming room
Return Value: Future<TUIValueCallBack<TUIRoomInfo>>

stopVoiceRoom

Anchor stops streaming and destroys the live room.
Future<TUIActionCallback> stopVoiceRoom()
Return Value: Future<TUIActionCallback>

joinVoiceRoom

Audience joins an anchor's live streaming room.
Future<TUIValueCallBack<TUIRoomInfo>> joinVoiceRoom(String roomId)
Parameters:
Parameter
Type
Meaning
roomId
String
Live Streaming Room ID
Return Value: Future<TUIValueCallBack<TUIRoomInfo>>

leaveVoiceRoom

Audience leaves an anchor's live streaming room.
Future<TUIActionCallback> leaveVoiceRoom()
Return Value: Future<TUIActionCallback>

updateRoomSeatMode

Update the seat mode of the room.
Future<TUIActionCallback> updateRoomSeatMode(TUISeatMode seatMode)
Parameters:
Parameter
Type
Meaning
seatMode
Free to Take: In free-speaking mode, the audience can freely join the podium without applying.
applyToTake: Audience become speakers only after the broadcaster agrees.
Return Value: Future<TUIActionCallback>

responseRemoteRequest

Anchor responds to microphone application / Audience responds to microphone invitation.
Future<TUIActionCallback> responseRemoteRequest(String userId, bool agree)
Parameters:
Parameter
Type
Meaning
userId
String
User ID that responds to the user. If the current identity is an audience, the ID can be left blank.
agree
bool
Whether to accept requests: true for accept, false for deny requests
Return Value: Future<TUIActionCallback>

cancelRequest

Anchor cancels microphone invitation / Audience cancels microphone application
Future<TUIActionCallback> cancelRequest(String userId)
Parameters:
Parameter
Type
Meaning
userId
String
User ID to be cancelled. If the current identity is an audience, the ID can be left blank.
Return Value: Future<TUIActionCallback>

takeSeat

Request to speak (application required in speaking mode)
Future<RequestCallback> takeSeat(int seatIndex, int timeout)
Parameters:
Parameter
Type
Meaning
index
int
Microphone position ID for speaking
timeout
int
Timeout period, in seconds. If set to 0, the SDK will not perform timeout detection or trigger a timeout callback.
Return Value: Future<RequestCallback>

moveToSeat

Remove seat (this function can only be invoked by the user already in the seat)
Future<TUIActionCallback> moveToSeat(int index)
Parameters:
Parameter
Type
Meaning
index
int
Microphone position ID that needs to be moved to
Return Value: Future<TUIActionCallback>

leaveSeat

Become a listener.
Future<TUIActionCallback> leaveSeat()
Return Value: Future<TUIActionCallback>

takeUserOnSeatByAdmin

Anchor invites users to speak.
Future<RequestCallback> takeUserOnSeatByAdmin(int seatIndex, String userId, int timeout)
Parameters:
Parameter
Type
Meaning
index
int
Invited microphone position ID
userId
String
ID of the invited user
timeout
int
Timeout period, in seconds. If set to 0, the SDK will not perform timeout detection or trigger a timeout callback.
Return Value: Future<RequestCallback>

kickUserOffSeatByAdmin

Anchor removes a user from the seat.
Future<TUIActionCallback> kickUserOffSeatByAdmin(String userId)
Parameters:
Parameter
Type
Meaning
userId
String
User ID of the kicked-off user
Return Value: Future<TUIActionCallback>

lockSeat

Mute a speaker. Anchor locks the seat (including position lock, audio status lock and video status lock)
Future<TUIActionCallback> lockSeat(int index, TUISeatLockParams lockMode)
Parameters:
Parameter
Type
Meaning
seatIndex
int
The microphone position ID that needs to be locked.
lockMode
Microphone Mute Parameters
Return Value: Future<TUIActionCallback>

setLayoutMode

Set the layout mode of the seat list.
void setLayoutMode(LayoutMode layoutMode, SeatWidgetLayoutConfig? layoutConfig)
Parameters:
Parameter
Type
Meaning
layoutMode
The layout mode of the seat position list supports focus layout, grid layout, vertical layout, and free layout.
layoutConfig
Layout configuration information only takes effect in free layout mode.
Return Value: void

addObserver

Set event callback.
void addObserver(SeatGridWidgetObserver observer)
Parameters:
Parameter
Type
Meaning
observer
Callback object of the core component
Return Value: void

removeObserver

Remove event callback.

void removeObserver(SeatGridWidgetObserver observer)
Parameters:
Parameter
Type
Meaning
observer
Callback object of the core component
Return Value: void

Type Definition

Type
Meaning
Custom seat widget constructor
Seat click event
Received room destruction event
Received event of being removed from room
Received request event to speak / Received invitation to speak event
Event of request to speak / invitation to speak being canceled
Received event of user removed from microphone
User audio status change event.
The layout mode of the seat position list supports focus layout, grid layout, vertical layout, and custom layout.
Alignment mode of seat layout
Request type (apply for microphone mode and invitation to speak)
Request result type
Request result callback
Seat layout configuration information
Seating layout row layout configuration information

SeatWidgetBuilder

Constructor of the custom seat widget
typedef SeatWidgetBuilder = Widget Function(
BuildContext context,
ValueNotifier<TUISeatInfo> seatInfoNotifier,
ValueNotifier<int> volumeNotifier);
Parameters:
Parameter
Type
Meaning
context
BuildContext
Context
seatInfoNotifier
ValueNotifier<TUISeatInfo>
Seat information notifier
volumeNotifier
ValueNotifier<int>
Volume information notifier

OnSeatWidgetTap

Seat click event
typedef OnSeatWidgetTap = void Function(TUISeatInfo seatInfo);
Parameters:
Parameter
Type
Meaning
seatInfo
Microphone position information

OnRoomDismissed

Received room destruction event
typedef OnRoomDismissed = void Function(String roomId);
Parameters:
Parameter
Type
Meaning
roomId
String
room ID

OnKickedOutOfRoom

Received event of being removed from room
typedef OnKickedOutOfRoom = void Function(String roomId, TUIKickedOutOfRoomReason reason, String message);
Parameters:
Parameter
Type
Meaning
roomId
String
room ID
reason
TUIKickedOutOfRoomReason
Reason for being kicked out
message
String
Kicked-out info

OnSeatRequestReceived

Received request event to speak / Received invitation to speak event
typedef OnSeatRequestReceived = void Function(RequestType type, TUIUserInfo userInfo);
Parameters:
Parameter
Type
Meaning
type
Request Type
userInfo
Requester Information

OnSeatRequestCancelled

Event of request to speak / invitation to speak being canceled
typedef OnSeatRequestCancelled = void Function(RequestType type, TUIUserInfo userInfo);
Parameters:
Parameter
Type
Meaning
type
Request Type
userInfo
Operator Information

OnKickedOffSeat

Received event of user removed from microphone
typedef OnKickedOffSeat = void Function(TUIUserInfo userInfo);
Parameters:
Parameter
Type
Meaning
userInfo
Operator Information

OnUserAudioStateChanged

User audio status change event
typedef OnUserAudioStateChanged = void Function(TUIUserInfo userInfo, bool hasAudio, TUIChangeReason reason);
Parameters:
Parameter
Type
Meaning
userInfo
Operator Information
hasAudio
bool
Whether there is an audio stream
reason
Reason for audio stream change

LayoutMode

Layout mode of the seat position list
Enumeration Value
Meaning
focus
Focus on layout
grid
Grid layout
vertical
Vertical layout
free
Custom Layout

SeatWidgetLayoutRowAlignment

Alignment mode of seat layout
Enumeration Value
Meaning
start
Move the seat closer to the starting position
end
Move the seat closer to the ending position
center
Move the seat closer to the intermediate position
spaceBetween
Do not leave space before the first seat and after the last seat. Evenly distribute the remaining space between other seats.
spaceAround
Distribute half of the space before the first seat and after the last seat. Evenly distribute the remaining space between other seats.
spaceEvenly
Evenly distribute the remaining space between all seats.

RequestType

Request Type
Enumeration Value
Meaning
applyToTakeSeat
Request to speak
inviteToTakeSeat
Invitation to speak

RequestResultType

Request to speak / Invitation to speak callback
Enumeration Value
Meaning
onAccepted
The request is accepted.
onRejected
Request rejected.
onCancelled
The request is canceled.
onTimeout
Request timeout
onError
Request anomaly

RequestCallback

Request result callback
Attribute
Type
Meaning
code
TUIError
Error Code Enumeration
message
String
Error code information
type
Request result type
userInfo
Request Processor

SeatWidgetLayoutRowConfig

Seating layout row layout configuration information
Attribute
Type
Meaning
count
int
Microphone Quantity Displayed in This Row
seatSpacing
double
Seat Horizontal Spacing in This Row (This Parameter Is Valid Only When the Alignment Mode Is START, END, and CENTER)
seatSize
Size
Seat Layout Size in This Row
alignment
Alignment mode of layout in this row

SeatWidgetLayoutConfig

Seat layout configuration information
Required
Type
Description
rowConfigs
Configuration information list of all rows in seat layout
rowSpacing
double
Line Spacing in Seat Layout

Event Definition

SeatGridWidgetObserver

Event List
Type
Meaning
onRoomDismissed
Received room destruction event
onKickedOutOfRoom
Received event of being removed from room
onSeatRequestReceived
Received request event to speak / Received invitation to speak event
onSeatRequestCancelled
Event of request to speak / invitation to speak being canceled
onKickedOffSeat
Received event of user removed from microphone
onUserAudioStateChanged
User audio status change event