Boemo is a software developer who embraces innovative approaches. He likes diving deep into complex concepts in order to learn and write articles that can help the reader understand complex methodologies in a simple and fun way.
Agora has many features that enhance video call quality and convenience. Muting audio and adjusting the video call’s volume are features that are necessary for any video call app.
In this tutorial, you will learn how to mute Agora video call audio and adjust the video call’s volume in Android using the Agora SDK.
Before we start coding, add the following dependencies in your build.gradle file in the app module, and sync to download the Agora third-party library. Ensure that you always use the latest Agora library version:
Add the following permissions in the Manifest.xml file:
Now, let’s create an RtcEngine instance by initializing the RtcEngine and passing the IRtcEngineEventHandler and your App ID to the create method. IRtcEngineEventHandler is an abstract class that provides the default implementation. We will use this object instance later to invoke the adjustPlaybackSignalVolume()method, which adjusts the volume of the video call:
Next, add the following code which sets the profile, orientation, and video configuration of the video call. Set the Channel profile as CHANNEL_PROFILE_COMMUNICATION. This enables all video call participants to send and receive voice and video in a one-to-one call:
A SeekBar is a ProgressBar that can be dragged left and right by a thumb. We will use the SeekBar to adjust the volume of the audio file being played or the video call’s volume.
Let’s start by creating a SeekBar object and calling the setOnSeekBarChangeListener:
To adjust the video call’s volume, we will use the adjustPlaybackSignalVolume() method and pass the progress value of the SeekBar to the adjustPlaybackSignalVolume() method. This method changes the volume of the video call.
The volume range of the Agora video call is from 0 to 100. The default volume is 100.
The onProgressChanged() method tracks changes made on the SeekBar when the user drags the SeekBar:
Next, implement the necessary methods of the SeekBar.OnSeekBarChangeListener interface. The onStartTrackingTouch() function adds a notification that the SeekBar has started tracking the user’s touch:
The onStopTrackingTouch() function adds a notification that the SeekBar has stopped tracking the user’s touch:
To mute the video call we have to set the volume to 0 using the adjustPlaybackSignalVolume() and adjustAudioMixingVolume() methods. Both of these methods must be used when muting the video call’s audio, and they can be called before or after joining a video call:
You have learned how to mute and adjust the volume using the Agora SDK methods in the previous sections. The following code block of the Mute class shows you how to integrate the mute and adjust volume features in a video streaming application:
If you are not familiar with building a one-to-one video call app using the Agora SDK, check this tutorial on GitHub written by Hermes. The above code follows the concepts taught in that tutorial.
In this tutorial we have learned how to:
Yay! you now know how to mute audio and adjust the volume using the Agora SDK.
Thank you for reading. You can learn more about how to adjust the volume here, and you can check out more Agora features on GitHub here. If you want to copy or reference the SDK I was using, check it on GitHub here.
If you get confused in the process, you can check out Agora’s documentation. You can also join Agora’s Slack channel here.