Live Audio Room Kit
  • iOS
  • Android : Java
  • Flutter
  • React Native
  • Overview
  • Quick start
  • Customize prebuilt features
    • Overview
    • Set avatar for users
    • Customize the seats
    • Customize the seat-taking logic
    • Customize the background
    • Customize user attributes
    • Set a leave confirmation dialog
    • Modify user interface text
    • Customize the bottom menu bar buttons
    • Customize the text message UI
  • Advanced features
    • Send virtual gifts
    • Use Tokens for authentication
  • API Reference
    • API
    • Event
  • Migration guide
    • Migrating to ZEGOCLOUD Maven
  • Documentation
  • Live Audio Room Kit
  • Quick start

Quick start

Last updated:2023-09-13 10:34

Prerequisites

​If you don't know how to create a project and obtain an app ID, please refer to this guide.

Integrate the SDK

Add ZegoUIKitPrebuiltLiveAudioRoom as dependencies

  1. Add the jitpack configuration.
  • If your Android Gradle Plugin is 7.1.0 or later: enter your project's root directory, open the settings.gradle file to add the jitpack to dependencyResolutionManagement > repositories like this:
dependencyResolutionManagement {
   repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
   repositories {
      google()
      mavenCentral()
      maven { url 'https://storage.zego.im/maven' }   // <- Add this line.
      maven { url 'https://www.jitpack.io' } // <- Add this line.
   }
}

If you can't find the above fields in settings.gradle, it's probably because your Android Gradle Plugin version is lower than v7.1.0.

For more details, see Android Gradle Plugin Release Note v7.1.0.

  • If your Android Gradle Plugin is earlier than 7.1.0: enter your project's root directory, open the build.gradle file to add the jitpack to allprojects->repositories like this:
allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://storage.zego.im/maven' }   // <- Add this line.
        maven { url "https://jitpack.io" }  // <- Add this line.
    }
}
  1. Modify your app-level build.gradle file:
    dependencies {
     ...
     implementation 'com.github.ZEGOCLOUD:zego_uikit_prebuilt_live_audio_room_android:+'    // Add this line to your module-level build.gradle file's dependencies, usually named [app].
    }

Using the Live Audio Room Kit

  • Specify the userID and userName for connecting the Live Audio Room Kit service.
  • Create a roomID that represents the live audio room you want to create.
  • userID, userName, and roomID can only contain numbers, letters, and underlines (_).
  • Using the same roomID will enter the same live audio room.

With the same roomID, only one user can enter the live audio room as host. Other users need to enter the live audio room as the audience.

Java Kotlin
public class LiveAudioRoomActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_call);

        addFragment();
    }

    public void addFragment() {
        long appID = yourAppID;
        String appSign = yourAppSign;
        String userID = yourUserID;
        String userName = yourUserName;

        boolean isHost = getIntent().getBooleanExtra("host", false);
        String roomID = getIntent().getStringExtra("roomID");

        ZegoUIKitPrebuiltLiveAudioRoomConfig config;
        if (isHost) {
            config = ZegoUIKitPrebuiltLiveAudioRoomConfig.host();
        } else {
            config = ZegoUIKitPrebuiltLiveAudioRoomConfig.audience();
        }

        ZegoUIKitPrebuiltLiveAudioRoomFragment fragment = ZegoUIKitPrebuiltLiveAudioRoomFragment.newInstance(
            appID, appSign, userID, userName,roomID,config);
        getSupportFragmentManager().beginTransaction()
            .replace(R.id.fragment_container, fragment)
            .commitNow();
    }
}
class LiveAudioRoomActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_live)
        addFragment()
    }

    private fun addFragment() {
        val appID: Long = yourAppID
        val appSign = yourAppSign
        val userID = YourUserID
        val userName = YourUserName

        val isHost = intent.getBooleanExtra("host", false)
        val roomID = intent.getStringExtra("roomID")

        val config: ZegoUIKitPrebuiltLiveAudioRoomConfig = if (isHost) {
            ZegoUIKitPrebuiltLiveAudioRoomConfig.host()
        } else {
            ZegoUIKitPrebuiltLiveAudioRoomConfig.audience()
        }
        val fragment = ZegoUIKitPrebuiltLiveAudioRoomFragment.newInstance(
            appID, appSign, userID, userName, roomID, config
        )
        supportFragmentManager.beginTransaction()
            .replace(R.id.fragment_container, fragment)
            .commitNow()
    }
}

Then, you can create a live audio room by starting your LiveAudioRoomActivity.

Run & Test

Now you have finished all the steps!

You can simply click the Run on Android Studio to run and test your App on the device.

Custom prebuilt UI

Resources

Page Directory