Skip to content
How to Create a NexPlayer and Agora Video Streaming Android App - featured

How to Create a NexPlayer and Agora Video Streaming Android App

By Author: Carlos Lucas In Developer

Carlos Lucas is the CEO of Nexplayer and has been working at NexStreaming for almost 20 years, leading the company’s transformation from a software provider to handset makers to becoming the market leader Player SDK for premium video service providers. Carlos is an engineer with an MBA and is passionate about creating innovations that help the global market.

Live streaming isn’t a new concept, but live streaming on multiple platforms can be time-consuming and expensive, and it can require technical know-how. Even if you can circumvent the technical part, you will still have to face some major hurdles:

  • Delayed time to market
  • Lack of content discovery
  • High latency
  • Poor video quality
  • Device fragmentation
  • Extensive device reach (securing the best quality across all devices)

So how do you reach your audiences wherever they are while still maintaining superior streaming quality?  

In this tutorial, we will walk you through how to use NexPlayer SDK integration with Agora Video Chat on Android. While this guide will focus on Android, the concepts can be applied to iOS and the Web.

Requirements for the implementation:

Now that you have all the requirements in place and ready, let’s get started. 

Initialize the Agora Video SDK

Locate your Agora Video SDK and begin initialization. This process allows you to initialize the Agora engine:

Setting Up Local Video

To set up your local video, you need to navigate to the root directory and create a root view, which  will allow you to see the video view: 

Setting Up Remote Video

The event handler delegates and checks to assess if there are any remote streams. If there are, the remote videos will be loaded:

Joining a Channel 

Join a channel with the default values. For this example, note that the token and channel name will be the same for this demo (read from remote):

Initializing the NexPlayer SDK

How to initialize NexPlayer SDK:

Opening a Stream

Click the NexPlayer and open a stream using the following format: 

Setting Up a Listener 

After you have opened a stream, set up a listener:

Creating Your App UI 

Great job so far. You are halfway through with the implementation. So far, we have initialized the Agora and NexPlayer SDKs and set up the remote videos. 

To set up a view, follow the activity_main.xml as shown below:

Important: On the LaunchActivity, you should request permissions for CAMERA and RECORD_AUDIO. If these permissions are not granted, you will not be able to join the room. The Agora SDK requires permissions to be granted in order to run this process. Once the permissions are granted, the MainActivity can be started. These steps must be followed in order to fully integrate both Agora and NexPlayer. 

Implementing Control Views

Let’s focus on how to join or leave a channel (Then create a initVideo method using the Boolean isOnChannel)

Using the call method, mute or unmute local video:
Note: You can use the change button image whether local audio is muted or not: 

Controlling the Player Volume

Follow the steps below to control the player volume, including pausing and resuming the player:

Controlling playback:

NexPlayer Control Methods

To initiate the NexPlayer control methods, follow the code:

void start()

boolean isPaused()

void pause()

void resume()

void setVolume(float fGain)


Build the app and install it on your devices. Ask a colleague to help you test the chat functionality from a remote device. Select JOIN PARTY in the application, and the default content will be played together with the video chat.

How to Create a NexPlayer and Agora Video Streaming Android App - screenshot #1

You are all set. Thanks for following this step-by-step tutorial on integrating the Agora and NexPlayer SDKs.