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 seats within the live room like applying to join the seat inviting to speak, moving microphone positions, and kicking someone off the seat.
API Overview
API | Description |
Create SeatGridView object | |
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 proxy for seat view | |
Set event callbacks | |
Remove event callbacks |
API Details
SeatGridView
Create an instance of SeatGridView object.
SeatGridView()
startMicrophone
Enable the local mic.
func startMicrophone(onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
stopMicrophone
Disable the local mic.
func stopMicrophone()
muteMicrophone
Pause publishing local audio stream.
func muteMicrophone()
unmuteMicrophone
Resume publishing local audio stream.
func unmuteMicrophone(onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
startVoiceRoom
Anchor creates live room and starts streaming.
func startVoiceRoom(roomInfo: TUIRoomInfo,onSuccess: @escaping SGOnRoomSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
roomInfo | TUIRoomInfo | Information for creating a live streaming room |
onSuccess | SGOnRoomSuccess | Success callback (with new live room information) |
onError | SGOnError | The failure callback |
stopVoiceRoom
Anchor stops streaming and destroys live room.
func stopVoiceRoom(onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
joinVoiceRoom
Audience joins an anchor's live room.
func joinVoiceRoom(roomId: String,onSuccess: @escaping SGOnRoomSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
roomId | String | Live Streaming Room ID |
onSuccess | SGOnRoomSuccess | Success callback (with live room information) |
onError | SGOnError | The failure callback |
leaveVoiceRoom
Audience leaves an anchor's live room.
func leaveVoiceRoom(onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
updateRoomSeatMode
Update Room Mic Mode.
func updateRoomSeatMode(seatMode: TUISeatMode,onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
seatMode | TUISeatMode | freeToTake: Free seat mode, audience can connect to seat freely without application; applyToTake: Apply seat mode, audience needs the anchor's approval to connect to seat. |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
responseRemoteRequest
Anchor Responds to Microphone Application/Audience Responds to Microphone Invitation.
func responseRemoteRequest(userId: String,agree: Bool,onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
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 | Bool | Whether to accept the request, true: accept the request, false: reject the request |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
cancelRequest
Anchor Cancels Microphone Invitation/Audience Cancels Microphone Application
func cancelRequest(userId: String,onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
userId | String | Cancelled user's ID, if the current role is an audience member, the ID can be left blank |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
takeSeat
Request to Speak (In speaking mode, application is required)
func takeSeat(index: Int,timeout: Int,onAccepted: @escaping SGOnRequestAccepted,onRejected: @escaping SGOnRequestRejected,onCancelled: @escaping SGOnRequestCancelled,onTimeout: @escaping SGOnRequestTimeout,onError: @escaping SGOnRequestError)
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 |
onAccepted | SGOnRequestAccepted | Application for seat has been approved callback |
onRejected | SGOnRequestRejected | Application for seat has been rejected callback |
onCancelled | SGOnRequestCancelled | Application for seat has been canceled callback |
onTimeout | SGOnRequestTimeout | Application for seat has timed out callback |
onError | SGOnRequestError | Application for seat error callback |
moveToSeat
Move Mic (only users who are already on the seat can call this function)
func moveToSeat(index: Int,onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
index | Int | Mic position number to move to |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
leaveSeat
Proactively disconnect mic
func leaveSeat(onSuccess: @escaping SGOnSuccess, onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
takeUserOnSeatByAdmin
Anchor Invites User to Connect Mic
func takeUserOnSeatByAdmin(index: Int,userId: String,onAccepted: @escaping SGOnRequestAccepted,onRejected: @escaping SGOnRequestRejected,onCancelled: @escaping SGOnRequestCancelled,onTimeout: @escaping SGOnRequestTimeout,onError: @escaping SGOnRequestError)
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 |
onAccepted | SGOnRequestAccepted | Invite to speak request approved callback |
onRejected | SGOnRequestRejected | Invite to speak request rejected callback |
onCancelled | SGOnRequestCancelled | Invite to speak request canceled callback |
onTimeout | SGOnRequestTimeout | Invite to speak request timeout callback |
onError | SGOnRequestError | Invite to speak request error callback |
kickUserOffSeatByAdmin
Anchor Kicks User off Mic
func kickUserOffSeatByAdmin(userId: String,onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
userId | String | User ID kicked off the Mic |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
lockSeat
Microphone Mute, Anchor locks Mic Position (including position lock, audio status lock, and video status lock)
func lockSeat(index: Int,lockMode: TUISeatLockParams,onSuccess: @escaping SGOnSuccess,onError: @escaping SGOnError)
Parameter:
Parameter | Type | Meaning |
seatIndex | int | Mic position number to be locked |
params | TUISeatLockParams | Microphone Mute Parameters. See details: TUIRoomDefine.SeatLockParams |
onSuccess | SGOnSuccess | The success callback |
onError | SGOnError | The failure callback |
setLayoutMode
Set the layout mode for the mic list.
func setLayoutMode(layoutMode: SGLayoutMode,layoutConfig: SeatViewLayoutConfig? = nil)
Parameter:
Parameter | Type | Meaning |
layoutModel | Layout mode of the mic list, supports element layout, grid layout, vertical layout, and free layout. | |
layoutConfig | Layout configuration information, effective only in free layout mode. |
setSeatViewDelegate
Set the adapter for the mic view.
func setSeatViewDelegate(_ delegate: SGSeatViewDelegate)
Parameter:
Parameter | Type | Meaning |
delegate | Seat view delegate |
addObserver
Set event callbacks.
func addObserver(observer: SeatGridViewObserver)
Parameter:
Parameter | Type | Meaning |
observer | Callback object of core component |
removeObserver
Remove event callbacks.
func removeObserver(observer: SeatGridViewObserver)
Parameter:
Parameter | Type | Meaning |
observer | Callback object of core component |
Type Definition
Type | Description |
Layout modes of the seat list support element layout, grid layout, vertical layout, and custom layout | |
Alignment of seat layout | |
Request type (apply to speak and invite to take seat) | |
Microphone position layout configuration information | |
Seating Layout Row Configuration Information | |
Seat view delegate |
SGLayoutMode
Layout modes of the seat list
Type | Description |
focus | Element Layout |
grid | Grid Layout |
vertical | Vertical layout |
free | Customized Layout |
SGSeatViewLayoutRowAlignment
Alignment of seat layout
Type | Description |
start | Microphone position near the start |
end | Microphone position near the end |
center | Microphone position near the middle |
spaceBetween | No space before the first and after the last seats, evenly distribute the remaining space between other seats |
spaceAround | Distribute half of the space before the first and after the last seats, evenly distribute the remaining space between other seats |
spaceEvenly | Evenly distribute the remaining space between all seats |
SGRequestType
Request type
Type | Description |
applyToTakeSeat | Apply to take seat |
inviteToTakeSeat | Invite to take seat |
SGSeatViewLayoutConfig
Microphone position layout configuration information
Type | Description |
rowConfigs | |
rowSpacing | Seat row spacing |
SGSeatViewLayoutRowConfig
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 |
SGSeatViewDelegate
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.
onAccepted: (_ userInfo: TUIUserInfo) -> Void
Parameter:
Parameter | Type | Description |
userInfo | TUIUserInfo | Response to the current request's user information |
onRejected
Application to speak/invite to speak request rejected.
onRejected: (_ userInfo: TUIUserInfo) -> Void
Parameter:
Parameter | Type | Description |
userInfo | TUIUserInfo | Response to the current request's user information |
onCancelled
Application to speak/invite to speak request canceled.
onCancelled: (_ userInfo: TUIUserInfo) -> Void
Parameter:
Parameter | Type | Description |
userInfo | TUIUserInfo | User information for the canceled request |
onTimeout
Application to speak/invite to speak request timed out.
onTimeout: (_ userInfo: TUIUserInfo) -> Void
Parameter:
Parameter | Type | Description |
userInfo | UserInfo | User information for the initiated request |
onError
Application to speak/invite to speak request error.
onError: (_ userInfo: TUIUserInfo, _ code: Int, _ message: String) -> Void
Parameter:
Parameter | Type | Description |
userInfo | TUIUserInfo | User information for the initiated request |
error | TUICommonDefine.Error | Error code |
message | String | Error message |
seatGridView:createSeatView
Callback when creating a single seat layout, you need to return your custom view, the core view will help you create the view.
func seatGridView(_ view: SeatGridView, createSeatView seatInfo: TUISeatInfo) -> UIView?
Parameter:
Parameter | Type | Description |
seatGridView | SeatGridView | Core components of voice chat room |
seatInfo | SeatInfo | Seat information |
Return value: UIView? (Use default seat view when the return value is nil)
seatGridView:updateSeatView
Callback when updating the seat view, you can update your seat view based on the seatInfo information returned by the callback.
func seatGridView(_ view: SeatGridView, updateSeatView seatInfo: TUISeatInfo, seatView: UIView)
Parameter:
Parameter | Type | Description |
seatGridView | SeatGridView | Core components of voice chat room |
seatInfo | TUISeatInfo | Seat information |
seatView | UIView | Current updated seat view |
seatGridView:updateUserVolume
Callback when updating user volume, you can update your seat view based on the returned volume.
func seatGridView(_ view: SeatGridView, updateUserVolume volume: CGFloat, seatView: UIView)
Parameter:
Parameter | Type | Description |
seatGridView | SeatGridView | Core components of voice chat room |
volume | CGFloat | Mic position volume information |
seatView | UIView | Current seat layout view with volume changes |
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
func onRoomDismissed(roomId: String)
Parameter:
Parameter | Type | Description |
roomId | String | Room ID |
onKickedOutOfRoom
Event of Being Kicked Out of the Room
func onKickedOutOfRoom(roomId: String,reason: TUIKickedOutOfRoomReason,message: String)
Parameter:
Parameter | Type | Description |
roomId | String | Room ID |
reason | TUIKickedOutOfRoomReason | Reason for Being Kicked Out |
message | String | Description of Being Kicked Out |
onSeatRequestReceived
Event of Request for Speaking/Invitation to Speak Received
func onSeatRequestReceived(type: SGRequestType,userInfo: TUIUserInfo)
Parameter:
Parameter | Type | Description |
type | Request type (Request for Speaking, Invitation to Speak) | |
userInfo | TUIUserInfo | Information of the user who sent the request |
onSeatRequestCancelled
Event of Request for Speaking/Invitation to Speak Canceled
func onSeatRequestCancelled(type: SGRequestType,userInfo: TUIUserInfo)
Parameter:
Parameter | Type | Description |
type | Request type (Request for Speaking, Invitation to Speak) | |
userInfo | TUIUserInfo | Information of the user who canceled the request |
onKickedOffSeat
Event of User Kicked Off Seat
func onKickedOffSeat(userInfo: TUIUserInfo)
Parameter:
Parameter | Type | Description |
userInfo | TUIUserInfo | Information of the host who kicked the user off the seat |
onUserAudioStateChanged
Event of User Audio Status Changed
func onUserAudioStateChanged(userInfo: TUIUserInfo,hasAudio: Bool,reason: TUIChangeReason)
Parameter:
Parameter | Type | Description |
userInfo | TUIUserInfo | User Information |
hasAudio | Bool | Is there an audio stream |
reason | TUIChangeReason | Reason for audio stream change |
onSeatViewClicked
Seat View Click Event
func onSeatViewClicked(seatView: UIView, seatInfo: TUISeatInfo)
Parameter:
Parameter | Type | Description |
seatView | View | Currently clicked seat view object |
seatInfo | TUISeatInfo | Seat information |
- 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
- setSeatViewDelegate
- addObserver
- removeObserver
- Type Definition
- Event Callback Details
- SeatGridViewObserver Overview
- SeatGridViewObserver Details