I'm using Google new MediaPlayer named ExoPlayer and cannot find a way to mute the sound
Is there an easy way to mute audio track on Google ExoPlayer ? Or changing volume ?
I'm using Google new MediaPlayer named ExoPlayer and cannot find a way to mute the sound
Is there an easy way to mute audio track on Google ExoPlayer ? Or changing volume ?
try
analogous to this line of code
The new way to mute and unmute volume as of version 2.3.1 can be done as follows:
make sure to call the line above after starting the player otherwise you will get a nullpointerexception
to mute volume:
to unmute volume:
I found two ways to achieve it by editing
DemoPlayer
from ExoPlayer.Good one :
Basicly, you need to get the
audioTrackRenderer
which is aExoPlayerComponent
and send message to it. So :Add
audioRenderer
member and set it inonRenderers
:Add public method :
Usage :
mute :
player.setMute(true);
unmute :
player.setMute(false);
The other one :
This is not a good solution has the player will need to rebuffer when unmuting.
Consist of changing the audio track to an empty one:
Just simply use player.setVolume(0) will silent the video.
I will recommend get the current volume first and then mute it. When you will unmute you can give user same volume.