How to Mute Audio and Adjust Volume During a Video Call in Android Using the Agora SDK

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.

Prerequisites and requirements

  • An Agora developer account (see How to Get Started with Agora).
  • Knowledge of how to create a live-streaming Android application using Agora. Check out the tutorial here.
  • Basic knowledge of Android development.
  • Android Studio.
  • An Android device.

Adding dependencies in Gradle

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:

Adding permissions in the Manifest.xml file

Add the following permissions in the Manifest.xml file:

Creating an instance of the RtcEngine

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:

Setting up the video call profile

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:

Adjusting the volume during a video call by dragging the SeekBar

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:

Muting the video call

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:

Integrating the mute and adjust volume features with the Agora Video Call SDK

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.

Testing the app demo

Summary

In this tutorial we have learned how to:

  • Track the user’s touch using a SeekBar
  • Adjust Agora video call volume
  • Mute audio during a video call

Conclusion

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.

Other resources

If you get confused in the process, you can check out Agora’s documentation. You can also join Agora’s Slack channel here.

This article was originally posted on the Agora Blog here:

How to Mute Audio and Adjust Volume During a Video Call in Android Using the Agora SDK

--

--

--

boemommopelwa@gmail.com|Android developer| Tech Enthusiast|Innovative thinking is my passion | Learn and experience more to discover more

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Android RecyclerView Part 2 — Creating RecyclerView with multiple view-types

QR code scanner using ZXing Library in Android

M-PESA Integration on Android — Part 1

Kotlin Multiplatform Is the Future of App Development

7 Quick Kotlin Tips for Android Developers

The Top 20 Android Studio Plugins

First Impression of Jetpack Compose, QoL Issues

Text Recognition from Images using Firebase ML Kit in Android

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Boemo Mmopelwa

Boemo Mmopelwa

boemommopelwa@gmail.com|Android developer| Tech Enthusiast|Innovative thinking is my passion | Learn and experience more to discover more

More from Medium

Network Data Transfer Using Volley Library— Android

Network call with kotlin coroutines

Find the data storage using Huawei Auth Service and Huawei CloudDB in Attendance Tracker Android…

Understanding Dynamic Feature Module — Part 2. Best Practices