I have 4 Videoview which is created dynamically. I want to set a custom volume for only one video which is coming from the server, the remaining three videos will be mute.
I want to set a custom volume for particular videos I tried below code it's not working
vid1.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
{
public void onPrepared(MediaPlayer mp)
{
//mp.setVolume(100f, 100f);
//mp.setLooping(true);
vid1.enableSound(20,mp); //here i will set music sound dynamically
vid1.start();
playingvideo1 = true;
}
});
//startTimeForContent = dateFormatForContent.format(new Date());
vid1.setOnErrorListener(mOnErrorListener2);
playBackfunction1();
}
public void enableSound(int sound, MediaPlayer mp){
Float f = Float.valueOf(sound);
Log.e("checkingsounds","&&&&& "+f);
mp.setVolume(f,f);
mp.setLooping(true);
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, sound, AudioManager.FLAG_PLAY_SOUND);
}
When I give volume 0 it is working...but when change 10,20,30 video is playing full sound....
I already research below:
sound volume not working on Android