Basic: Starting a Live Voice Broadcast

There is a new release of the Developer Center! If you'd like to check it out, please click  here

Basic: Starting a Live Voice Broadcast

Getting Started

You can download either the Voice SDK or Video SDK to start a live voice broadcast.

Agora recommends downloading the Video SDK, which includes both voice and video functions for more flexibility. You can:

  • Disable the video function if you only need the voice function, or
  • Enable the video function if you need both.

Step 1: Prepare the Environment

  1. Download the Video SDK.
  2. Hardware and software requirements:
    • Android 4.1 and later devices with audio and video support
    • Android SDK API 16 or later
    • Android Studio 2.0 or later
  3. Before accessing Agora’s services, make sure that you have connected to the ports and whitelisted the domains as specified in Firewall Requirements .

Step 2: Add the SDK

  1. Copy the following libraries from the libs folder according to your needs.

    • agora-rtc-sdk.jar (mandatory)
    • armeabi-v7a/
    • x86/
    • arm64-v8a
    • include

    Note

    When you copy the libraries to the libs folder in the targeted path, if there is any Chinese character in the path, the sample code will not be compiled successfully, and will display random ASCII code in the error message.

  2. Put the required libraries in the correct libs path according to the settings in the build.gradle file.

    ../_images/android_library.png
  3. Specify the directory of the so file in the build.gradle file as the path of the abovementioned libs folder.

    ../_images/android_so.png

Step 3: Configure the NDK

If the following error displays, it means that the NDK is not installed.

../_images/android6.png

Download the NDK from the Android developer website, and put it in the Android location, for example,

../_images/android7.png

Step 4: Add the Permissions

The following permissions are required in the AndroidManifest.xml file for your application when deployed:

  • <uses-permission android:name=”android.permission.INTERNET” />
  • <uses-permission android:name=”android.permission.RECORD_AUDIO” />
  • <uses-permission android:name=”android.permission.CAMERA” />
  • <uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” />
  • <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />

Step 5: Synchronize with the Project Files

Click Sync Project With Gradle Files until the synchronization is complete.

../_images/android9.png

Step 6: Obfuscate the Code

Add the following line to obfuscate the code:

-keep class io.agora.**{*;}

Scenario 1: Starting a Live Voice Broadcast

Use the following code snippets to start your first live voice broadcast.

//create an RtcEngine object, and fill in the App ID
RtcEngine rtcEngine = RtcEngine.create(ctx, "74******************************a", myRtcEventHandler);

//set the channel as live broadcast mode
rtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);

//set the user role as host
rtcEngine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER)

//create and join a channel
rtcEngine.joinChannel(null, "channelName", null, myUid)

You can now start a live voice broadcast.

See the following APIs for more information:

Scenario 2: Implementing other functions

The following functions can be implemented in a live voice broadcast:

Agora will provide the API call sequences and sample code for the following functions later. In the meantime, refer to Interactive Broadcast API:

  • Capturing raw voice data
  • Playing Werewolf (Mafia)
Is this page helpful?