This document guides developers through building a voice chat room application with host broadcasting and audience participation features using the AtomicXCore SDK's LiveListStore and LiveSeatStore.
Core Concepts
Core Concept
Type
Core Responsibilities & Description
LiveListStore
abstract class
createLive(): Start live stream as host.
endLive(): End live stream as host.
joinLive(): Audience joins live room.
leaveLive(): Leave live room.
LiveInfo
data class
liveID: Unique room identifier.
seatLayoutTemplateID: Layout template ID (e.g., 600 for dynamic grid).
LiveSeatStore
abstract class
Core seat management class. Manages all seat information and seat-related operations in the room.
Provides a real-time seat list data stream via liveSeatState.seatList.
LiveSeatState
data class
Represents the current state of all seats.
seatList: a StateFlow containing the real-time seat list.
speakingUsers: users currently speaking and their volume.
SeatInfo
data class
Data model for a single seat. The seat list (seatList) emitted by LiveSeatStore is a list of SeatInfo objects.
Key fields:
index: seat position.
isLocked: whether the seat is locked.
userInfo: user information for the seat. If the seat is empty, this field is empty.
SeatUserInfo
data class
Detailed data model for the user occupying a seat. When a user successfully takes a seat, the userInfo field in SeatInfo is populated.
Key fields:
userID: unique user ID.
userName: user nickname.
avatarURL: user avatar URL.
microphoneStatus: microphone status (on/off).
cameraStatus: camera status (on/off).
Prerequisites
Step 1: Activate the Service
See Activate Service to obtain either the trial or paid version of the SDK.Then, go to the Console for application management, and get the following:
SDKAppID: Application identifier (required). Tencent Cloud uses SDKAppId for billing and details.
SDKSecretKey: Application secret key, used to initialize the configuration file with secret information.
Step 2: Import AtomicXCore into Your Project
Install the component: Add the dependency implementation 'com.tencent.atomicx:atomicxcore:latest' to your build.gradle file, then perform a GradleSync.
The unique ID for the current user. Must contain only English letters, numbers, hyphens, and underscores.
userSig
String
A ticket for Tencent Cloud authentication. Please note:
Development Environment: You can use the local GenerateTestUserSig.genTestSig function to generate a UserSig or generate a temporary UserSig via the UserSig Generation Tool.
Production Environment: To prevent key leakage, you must use a server-side method to generate UserSig. For details, see Generating UserSig on the Server.
Mic seat mode (FREE: free to take seat, APPLY: apply to take seat)
seatLayoutTemplateID
Int
Required
Mic seat layout template ID
coverURL
String
Optional
Cover image URL for the live room
backgroundURL
String
Optional
Background image URL for the live room
categoryList
List<Int>
Optional
Category tag list for the live room
activityStatus
Int
Optional
Live activity status
4. Build the Mic Seat UI
Note:
For the complete business logic of mic seat UI effects, refer to the open-source SeatGridView.kt in the TUILiveKit project.
Use the LiveSeatStore instance to observe changes in liveSeatState.seatList and update your UI in real time. In your Activity (such as YourAnchorActivity or YourAudienceActivity), observe the data as follows:
importandroid.os.Bundle
importandroid.util.Log
importandroidx.appcompat.app.AppCompatActivity
importkotlinx.coroutines.CoroutineScope
importkotlinx.coroutines.Dispatchers
importkotlinx.coroutines.launch
classYourHostActivity:AppCompatActivity(){
// ... Other code ...
override fun onCreate(savedInstanceState:Bundle?){
super.onCreate(savedInstanceState)
// ... Other code ...
// Listen for seatList changes
observeSeatList()
}
private fun observeSeatList(){
// Listen for seatList changes and update your mic seat UI
// Ensure this is also called when the Activity is destroyed
override fun onDestroy(){
super.onDestroy()
leaveLive()
Log.d("Live","YourAudienceActivity onDestroy")
}
}
Run and Test
After completing the steps above, you will have a basic voice chat live streaming setup. For more advanced features, see the "Enrich Voice Chat Room Scenarios" section.
Advanced Features
Implementing Speaking Wave Animation for Mic Seat Users
In voice chat rooms, it is common to show a wave animation on the avatar of users who are speaking, so everyone can see who is currently talking. LiveSeatStore provides a speakingUsers data stream for this purpose.
Example
Implementation
Note:
For a complete implementation of the speaking wave animation, refer to SeatGridView.kt in the open-source TUILiveKit project.
In YourAnchorActivity, observe changes in speakingUsers and update the UI to reflect the speaking status:
importandroid.os.Bundle
importandroid.util.Log
importandroidx.appcompat.app.AppCompatActivity
importkotlinx.coroutines.CoroutineScope
importkotlinx.coroutines.Dispatchers
importkotlinx.coroutines.launch
// In YourHostActivity or YourAudienceActivity
classYourHostActivity:AppCompatActivity(){
// ... (omitting other code) ...
override fun onCreate(savedInstanceState:Bundle?){
super.onCreate(savedInstanceState)
// ... (omitting other code) ...
// Listen for speakingUsers changes
observeSpeakingUsersState()
}
private fun observeSpeakingUsersState(){
// Listen for speakingUsers changes and update the "currently speaking" status
In Live Streaming Room, hosts may need to synchronize custom information with all participants, such as the current room topic or background music. The metaData feature of LiveListStore supports this use case.
Implementation
1. On the host side, set custom information using the updateLiveMetaData API. AtomicXCore synchronizes these changes in real time to all participants.
2. On the audience side, subscribe to LiveListState.currentLive and listen for changes in metaData. When a relevant key is updated, parse its value and update your business logic.
Manages the full lifecycle of live rooms: create, join, leave, destroy rooms; query room list; modify live info (name, announcement, etc.); listen to live status (such as being kicked out, ended).
Why is there no sound after the audience calls joinLive?
Check device permissions: Ensure the app has system permission to use the microphone.
Check the host: Confirm the host has called DeviceStore.shared().openLocalMicrophone(null) to enable the microphone.
Check the network: Ensure the device's network connection is stable.
Why is the mic seat list not displayed or not updating?
Check store initialization: Make sure you have created the LiveSeatStore instance with the same liveID before calling createLive or joinLive (LiveSeatStore.create(liveID)).
Check data observation: Ensure you are observing the liveSeatStore.liveSeatState.seatList data stream.
Check API calls: Confirm that createLive (host) or joinLive (audience) was successfully called (check the onSuccess callback).åå