SeatGridView
API Introduction
SeatGridView is a basic control we developed for the Voice Chat Room UIKit. This core control provides rich APIs such as opening/closing the voice chat room, managing seat positions within the live room like applying to join the seat, inviting to take seat, moving seat positions, and kicking someone off the seat.
API Overview
API | Description |
Create a SeatGridView object, supporting code creation and XML loading . | |
Enable local microphone | |
Disable local microphone | |
Pause publishing local audio stream | |
Resume publishing local audio stream | |
Anchor creates live room and starts streaming | |
Anchor stops streaming and destroys live room | |
Audience joins an anchor's live room | |
Audience leaves an anchor's live room | |
Update Room Mic Mode | |
Anchor Responds to Microphone Application/Audience Responds to Microphone Invitation | |
Anchor Cancels Microphone Invitation/Audience Cancels Microphone Application | |
Connect Mic | |
Disconnect Mic | |
Disconnect Mic | |
Anchor Invites User to Connect Mic | |
Anchor Kicks User off Mic | |
Anchor Locks Mic Position (including position lock, audio status lock, and video status lock) | |
Anchor Sets Layout Mode for Mic List | |
Set the adapter for the seat view | |
Set event callbacks | |
Remove event callbacks |
API Details
SeatGridView
Create a SeatGridView object instance. Supports code creation and XML loading.
public SeatGridView(Context context)
Parameter:
Parameter | Type | Meaning |
context | Context | Android context object |
Return Value:SeatGridView
startMicrophone
Enable the local mic.
void startMicrophone(ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Return Value:void
stopMicrophone
Disable the local mic.
void stopMicrophone()
Return Value:void
muteMicrophone
Pause publishing local audio stream.
void muteMicrophone()
Return Value:void
unmuteMicrophone
Resume publishing local audio stream.
void unmuteMicrophone(ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Return Value:void
startVoiceRoom
Anchor creates live room and starts streaming.
void startVoiceRoom(RoomInfo roomInfo, GetRoomInfoCallback callback)
Parameter:
Parameter | Type | Meaning |
roomInfo | RoomInfo | Information for creating a live streaming room |
callback | ActionCallback | Callback of the operation |
Return Value:void
stopVoiceRoom
Anchor stops streaming and destroys live room.
void stopVoiceRoom(ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Return Value:void
joinVoiceRoom
Audience joins an anchor's live room.
void joinVoiceRoom(String roomId, GetRoomInfoCallback callback)
Parameter:
Parameter | Type | Meaning |
roomId | String | Live Streaming Room ID |
callback | ActionCallback | Callback of the operation |
Return Value:void
leaveVoiceRoom
Audience leaves an anchor's live room.
void leaveVoiceRoom(ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Return Value:void
updateRoomSeatMode
Update Room Mic Mode.
void updateRoomSeatMode(SeatMode seatMode, ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
seatMode | SeatMode | FREE_TO_TAKE: Free seat mode, audience can join the seat freely without application; APPLY_TO_TAKE: Apply to join the seat mode, audience needs the anchor's consent to join the seat. |
callback | ActionCallback | Callback of the operation. |
Return Value:void
responseRemoteRequest
Anchor Responds to Microphone Application/Audience Responds to Microphone Invitation.
void responseRemoteRequest(String userId, boolean agree, ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
userId | String | Responding user's user ID, if the current role is an audience member, the ID can be left blank |
agree | boolean | Whether to accept the request, true: accept the request, false: reject the request |
callback | ActionCallback | Callback of the operation |
Return Value:void
cancelRequest
Anchor Cancels Microphone Invitation/Audience Cancels Microphone Application
void cancelRequest(String userId, ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
userId | String | Cancelled user's ID, if the current role is an audience member, the ID can be left blank |
callback | ActionCallback | Callback of the operation |
Return Value:void
takeSeat
Request to Speak (In speaking mode, application is required)
void takeSeat(int index, int timeout, VoiceRoomDefine.RequestCallback callback)
Parameter:
Parameter | Type | Meaning |
index | int | Mic position number for connecting |
timeout | int | Timeout period, unit: seconds. If set to 0, the SDK will not perform a timeout check or trigger a timeout callback |
callback | ActionCallback | Callback of the operation |
Return Value:void
moveToSeat
Move Mic (only users who are already on the seat can call this function)
void moveToSeat(int index, ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
index | int | Mic position number to move to |
callback | ActionCallback | Callback of the operation |
Return Value:void
leaveSeat
Proactively leave seat
void leaveSeat(ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Return Value:void
takeUserOnSeatByAdmin
Anchor Invites User to Connect Mic
void takeUserOnSeatByAdmin(int index, String userId, int timeout, VoiceRoomDefine.RequestCallback callback)
Parameter:
Parameter | Type | Meaning |
index | int | Invited Mic position number |
userId | String | Invited user ID |
timeout | int | Timeout period, unit: seconds. If set to 0, the SDK will not perform a timeout check or trigger a timeout callback |
callback | VoiceRoomDefine.RequestCallback | Callback of the operation |
Return Value:void
kickUserOffSeatByAdmin
Anchor Kicks User off Mic
void kickUserOffSeatByAdmin(String userId, ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
userId | String | User ID kicked off the Mic |
callback | ActionCallback | Callback of the operation |
Return Value:void
lockSeat
Microphone Mute, Anchor locks Mic Position (including position lock, audio status lock, and video status lock)
void lockSeat(int seatIndex, TUIRoomDefine.SeatLockParams params, ActionCallback callback)
Parameter:
Parameter | Type | Meaning |
seatIndex | int | Mic position number to be locked |
params | TUIRoomDefine.SeatLockParams | Microphone Mute Parameters. See details: TUIRoomDefine.SeatLockParams |
callback | ActionCallback | Callback of the operation |
Return Value:void
setLayoutMode
Set the layout mode for the mic list.
void setLayoutMode(LayoutMode layoutModel, SeatViewLayoutConfig layoutConfig)
Parameter:
Parameter | Type | Meaning |
layoutModel | Mic list layout modes, support element layout, grid layout, vertical layout, custom layout. | |
layoutConfig | Layout configuration information, effective only in custom layout mode |
Return Value:void
setSeatViewAdapter
Set the adapter for the mic view.
void setSeatViewAdapter(VoiceRoomDefine.SeatViewAdapter adapter)
Parameter:
Parameter | Type | Meaning |
adapter | Seat view adapter |
Return Value:void
addObserver
Set event callbacks.
void addObserver(SeatGridViewObserver observer)
Parameter:
Parameter | Type | Meaning |
observer | Callback object of core component |
Return Value:void
removeObserver
Remove event callbacks.
void removeObserver(SeatGridViewObserver observer)
Parameter:
Parameter | Type | Meaning |
observer | Callback object of core component |
Return Value:void
Type Definition
Type | Description |
Layout modes of the seat position list support element layout, grid layout, vertical layout, and custom layout | |
Alignment of seat position layout | |
Request type (apply to speak and invite to speak) | |
Size of the seat position layout | |
Microphone position layout configuration information | |
Seating Layout Row Configuration Information | |
Request Callback | |
Seat view adapter |
LayoutMode
Layout modes of the seat position list
Type | Description |
FOCUS | Element Layout |
GRID | Grid Layout |
VERTICAL | Vertical layout |
FREE | Customized Layout |
SeatViewLayoutRowAlignment
Alignment of seat position layout
Type | Description |
START | Seat position near the start |
END | Seat position near the end |
CENTER | Seat position near the middle |
SPACE_BETWEEN | No space before the first and after the last seat positions, evenly distribute the remaining space between other seat positions |
SPACE_AROUND | Distribute half of the space before the first and after the last seat positions, evenly distribute the remaining space between other seat positions |
SPACE_EVENLY | Evenly distribute the remaining space between all seat positions |
RequestType
Request type
Type | Description |
APPLY_TO_TAKE_SEAT | Apply to speak |
INVITE_TO_TAKE_SEAT | Invite to speak |
Size
Size of the seat position layout
Type | Description |
width | Layout width |
height | Layout height |
SeatViewLayoutConfig
Microphone position layout configuration information
Type | Description |
rowConfigs | List of all row configuration information in the seat layout, refer to SeatViewLayoutRowConfig for content. |
rowSpacing | Seat row spacing |
SeatViewLayoutRowConfig
Seating Layout Row Configuration Information
Type | Description |
count | Number of seats displayed in this row |
seatSpacing | Horizontal spacing of each seat in this row (effective only when the alignment is START, END, or CENTER) |
seatSize | Size of the seat layout in this row |
alignment |
RequestCallback
Request to speak/Invite to speak callback
API | Description |
Request accepted | |
Request rejected | |
Request canceled | |
Request timeout | |
Request Exception |
SeatViewAdapter
Seat View Adapter Interface, you can customize the display UI of each seat by implementing this interface.
API | Description |
Callback when creating a single seat layout. | |
Callback when updating the seat view. | |
Callback when updating user volume. |
Event Callback Details
onAccepted
Application to speak/invite to speak request accepted.
void onAccepted(TUIRoomDefine.UserInfo userInfo);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | Response to the current request's user information |
Returned value: void
onRejected
Application to speak/invite to speak request rejected.
void onRejected(TUIRoomDefine.UserInfo userInfo);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | Response to the current request's user information |
Returned value: void
onCancelled
Application to speak/invite to speak request canceled.
void onCancelled(TUIRoomDefine.UserInfo userInfo);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | User information for the canceled request |
Returned value: void
onTimeout
Application to speak/invite to speak request timed out.
void onTimeout(TUIRoomDefine.UserInfo userInfo);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | User information for the initiated request |
Returned value: void
onError
Application to speak/invite to speak request error.
void onError(TUIRoomDefine.UserInfo userInfo, TUICommonDefine.Error error, String message);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | User information for the initiated request |
error | TUICommonDefine.Error | Error code |
message | String | Error message |
Returned value: void
createSeatView
Callback when creating a single seat layout, you need to return your custom view, and the core view will help you create the view.
View createSeatView(SeatGridView seatGridView, TUIRoomDefine.SeatInfo seatInfo);
Parameter:
Parameter | Type | Description |
seatGridView | SeatGridView | Core components of voice chat room |
seatInfo | SeatInfo | Seat information |
Returned value: View
updateSeatView
Callback when updating the seat view, you can update your seat view based on the seatInfo information returned by the callback.
void updateSeatView(SeatGridView seatGridView, TUIRoomDefine.SeatInfo seatInfo, View seatView);
Parameter:
Parameter | Type | Description |
seatGridView | SeatGridView | Core components of voice chat room |
seatInfo | SeatInfo | Seat information |
seatView | View | Current updated seat view |
Return Value:void
updateUserVolume
Callback when updating user volume, you can update your seat view based on the returned volume.
void updateUserVolume(SeatGridView seatGridView, int volume, View seatView);
Parameter:
Parameter | Type | Description |
seatGridView | SeatGridView | Core components of voice chat room |
volume | int | Volume level |
seatView | View | Current seat layout view with volume changes |
Return Value:void
SeatGridViewObserver Overview
Function List | Description |
Event of Room Termination Received | |
Event of Being Kicked Out of the Room Received | |
Event of Request for Speaking/Invitation to Speak Received | |
Event of Request for Speaking/Invitation to Speak Canceled | |
Event of User Kicked Off Seat Received | |
Event of User Audio Status Changed | |
Seat View Click Event |
SeatGridViewObserver Details
onRoomDismissed
Event of Live Room Destroyed
void onRoomDismissed(String roomId);
Parameter:
Parameter | Type | Description |
roomId | String | Room ID |
Return Value:void
onKickedOutOfRoom
Event of Being Kicked Out of the Room
void onKickedOutOfRoom(String roomId, TUIRoomDefine.KickedOutOfRoomReason reason, String message);
Parameter:
Parameter | Type | Description |
roomId | String | Room ID |
reason | KickedOutOfRoomReason | Reason for Being Kicked Out |
message | String | Description of Being Kicked Out |
Return Value:void
onSeatRequestReceived
Event of Request for Speaking/Invitation to Speak Received
void onSeatRequestReceived(VoiceRoomDefine.RequestType type, TUIRoomDefine.UserInfo userInfo);
Parameter:
Parameter | Type | Description |
type | Request type (Request for Speaking, Invitation to Speak) | |
userInfo | UserInfo | Information of the user who sent the request |
Return Value:void
onSeatRequestCancelled
Event of Request for Speaking/Invitation to Speak Canceled
void onSeatRequestCancelled(VoiceRoomDefine.RequestType type, TUIRoomDefine.UserInfo userInfo);
Parameter:
Parameter | Type | Description |
type | Request type (Request for Speaking, Invitation to Speak) | |
userInfo | UserInfo | Information of the user who canceled the request |
Return Value:void
onKickedOffSeat
Event of User Kicked Off Seat
void onKickedOffSeat(UserInfo userInfo);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | Information of the host who kicked the user off the seat |
Return Value:void
onUserAudioStateChanged
Event of User Audio Status Changed
void onUserAudioStateChanged(UserInfo userInfo, boolean hasAudio, TUIRoomDefine.ChangeReason reason);
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | User Information |
hasAudio | boolean | Is there an audio stream |
reason | ChangeReason | Reason for audio stream change |
Return Value:void
onSeatViewClicked
Seat View Click Event
void onSeatViewClicked(View seatView, TUIRoomDefine.SeatInfo seatInfo);
Parameter:
Parameter | Type | Description |
seatView | View | Currently clicked seat view object |
seatInfo | SeatInfo | Seat information |
Return Value:void
- API Introduction
- API Overview
- API Details
- SeatGridView
- startMicrophone
- stopMicrophone
- muteMicrophone
- unmuteMicrophone
- startVoiceRoom
- stopVoiceRoom
- joinVoiceRoom
- leaveVoiceRoom
- updateRoomSeatMode
- responseRemoteRequest
- cancelRequest
- takeSeat
- moveToSeat
- leaveSeat
- takeUserOnSeatByAdmin
- kickUserOffSeatByAdmin
- lockSeat
- setLayoutMode
- setSeatViewAdapter
- addObserver
- removeObserver
- Type Definition
- Event Callback Details
- SeatGridViewObserver Overview
- SeatGridViewObserver Details