Because of a conversation with Musk, ClubHouse caught fire worldwide and reached a staggering 9.6 million monthly downloads.
Faced with a new social model, how to quickly clone Clubhouse‘s social gameplay and enrich the forms of interaction on your own application.
Understand the process
The following diagram shows the basic process of creating a live audio room and taking speaker seats to speak:
Integrate the zegoliveaudioroom SDK
To integrate the SDK, do the following:
1) Download the Sample codes, copy the
zegoliveaudioroom module to your project (if you have no project, create a new one).
2) Add the following code to the
3) Modify the
build.gradle file of your application, add the following code to the
4) Modify the
build.gradle file of your project, add the following code to the
Permissions can be set as needed.
Open the file
app/src/main/AndroidManifest.xml, and add the following code:
Note: For Android 6.0 or later, some important permissions must be requested at runtime rather than declared statically in the file
AndroidMainfest.xml, therefore, you need to add the following code to do so (requestPermissions is a method of an Android Activity).
Prevent class name obfuscation
To prevent the ZEGOCLOUD SDK public class names from being obfuscated, you can add the following code in the file
Initialize the zegoliveaudioroom SDK
To initialize the zegoliveaudioroom SDK, get the
ZegoRoomManager instance, pass the AppIDof your project.
To receive event callbacks, call the
setListener to listen for and handle various events as needed.
To access the signaling service of Live Audio Room with the
zegoliveaudioroom SDK, you must log in first.
Create/Join a live audio room
- You become a Host after creating a live audio room, and you owe more permissions, such as closing untaken speaker seats, removing a specified listener from the speaker seat, etc.
- You become a Listener after joining a live audio room, you can take a speaker seat to be a speaker or leave the speaker seat to become a listener again.
To create a live audio room, call the
To join a live audio room, call the
Send/Receive messages in the room
In a live audio room, both Host and Listeners can send and receive messages.
To send messages, call the
sendTextMessage method with the message content.
To receive messages, listen for the
Take a speaker seat
To take a speaker seat to speak, call the
takeSeat method. And the SDK publishes streams simultaneously.
When there is a new listener takes a seat and becomes a speaker, all participants in the room receive notifications through the
ZegoSpeakerSeatServiceListener callback. You can set up a UI refresh action for this callback as needed.
Sign up with ZEGOCLOUD, and get 10,000 minutes free every month.