Audience Connection

Description of the Feature

The 'audience mic link' feature is a real-time interactive communication method. By using the audience mic link feature, hosts can interact in real time with up to 9 audience members, whether it's answering questions, sharing experiences, or engaging in entertainment interactions, all of which significantly enhance the audience's engagement and satisfaction. This direct interaction and communication provide a more convenient and efficient channel for commercial operations and also offer the audience a more personalized and customized shopping experience. The audience mic link feature is suitable for multiple scenarios, including e-commerce live streaming, entertainment live streaming, and online teaching.
Solo microphone connection
Group Mic Connection







Access Process

Audience mic connection process

TUILiveKit audience mic connection feature is mainly implemented through LiveCoreView. You can call the following API functions to implement the audience mic connection feature. As an example, audience B requests to connect with anchor A as follows.
Note:
The methods described below are actively invoked and provided by LiveCoreView.
All callback methods refer to the callback methods in the ConnectionObserver object set by LiveCoreView.

Audience sends mic connection request

Audience B sends a mic connection request to anchor A. Anchor A will receive audience B's mic connection request in the onUserConnectionRequest callback.
Kotlin
Java
val userId = "anchorUserId";
val timeout = 60;
liveCoreView.requestIntraRoomConnection(userId, 10, null)
String userId = "anchorUserId";
int timeout = 60;
liveCoreView.requestIntraRoomConnection(userId, timeout, true, null);

Host end receives mic connect request

Anchor A will receive audience B's mic connection request in the onUserConnectionRequest callback method.
Kotlin
Java
override fun onUserConnectionRequest(inviterUser: UserInfo) {
Log.i(TAG, "Received audience connection request:${inviterUser.userId}")
}
@Override
public void onUserConnectionRequest(LiveStreamDefine.LiveUser inviterUser) {
Log.i(TAG, "Received viewer connection request:" + inviterUser.userId);
}

Anchor responds to mic connection request

After anchor A receives the audience's mic connection request, they can call respondIntraRoomConnection to respond to whether they agree to audience B's mic connection.
Kotlin
Java
// Anchor agrees to mic connection
liveCoreView.respondIntraRoomConnection(audienceBUserId, true, null)
// Anchor agrees to mic connection
liveCoreView.respondIntraRoomConnection(userId, true, null);

// Anchor rejects mic connection
liveCoreView.respondIntraRoomConnection(userId, false, null);

Audience receives anchor response callback

After anchor A agrees to audience B's mic connection request, audience B will receive anchor A's acceptance callback via the onUserConnectionAccepted callback.
Kotlin
Java
override fun onUserConnectionAccepted(inviterUser: UserInfo) {
Log.i(TAG, "Audience accepts the connection:${inviterUser.userId}")
}
@Override
public void onUserConnectionAccepted(LiveStreamDefine.LiveUser liveUser) {
Log.i(TAG, "Audience agreed to connect:" + liveUser.userId);
}

@Override
public void onUserConnectionRejected(LiveStreamDefine.LiveUser liveUser) {
Log.i(TAG, "Audience rejected the connection:" + liveUser.userId);
}

Callback for changes in the list of mic-connected users

After anchor A agrees to audience B's mic connection request, LiveCoreView will send the change notification to both anchor A and audience B.
Kotlin
Java
override fun onConnectedUsersUpdated(inviterUser: UserInfo) {
Log.i(TAG, "Mic-connected user list changed")
}
@Override
public void onConnectedUsersUpdated(List<UserInfo> userList, List<UserInfo> joinList, List<UserInfo> leaveList) {
Log.i(TAG, "The list of connected users has changed");
}

Mic connection disconnection process

After audience's mic connect succeeds, host hangs up the mic connect

After audience B and anchor A successfully connect their mics, anchor A disconnects the mic connection with audience B.
Kotlin
Java
val userId = "audienceBUserId"
liveCoreView.disconnectUser(userId, null)
String userId = "audienceUserId";
liveCoreView.disconnectUser(userId, null);

The audience receives a callback when the host disconnects.

After anchor A disconnects the mic connection with audience B, audience B will receive the onUserConnectionTerminated callback.
Kotlin
Java
override fun onUserConnectionTerminated(inviterUser: UserInfo) {
Log.i(TAG, "Anchor disconnected the mic connection")
}
@Override
public void onUserConnectionTerminated() {
Log.i(TAG, "The host has closed the connection");
}

After audience's mic connect succeeds, audience ends the mic connect

After audience B and anchor A successfully connect their mics, audience B can proactively disconnect the mic connection by calling terminateIntraRoomConnection.
Kotlin
Java
liveCoreView.terminateIntraRoomConnection()
liveCoreView.terminateIntraRoomConnection();

Anchor receives the callback for audience disconnecting the mic connection

When audience B proactively disconnects the mic connection, the anchor will receive the onUserConnectionExited callback.
Kotlin
Java
override fun onUserConnectionExited(inviterUser: LiveStreamDefine.LiveUser) {
Log.i(TAG, "Audience disconnected the mic connection")
}
@Override
public void onUserConnectionExited(UserInfo liveUser) {
Log.i(TAG, "Viewer exited connection:${liveUser.userId}");
}
Note:
The connection feature is implemented based on LiveCoreView. If you need to extend the connection feature, refer to the LiveCoreView documentation.

Audience mic connection timing diagram