I am showing the list of videos using TextureView
and MediaPlayer
. I want to mute/unmute sound for all videos.
What is the problem
Problem is that when I use notifyDataSetChanged()
method then the playing video gets reloaded because onBindViewHolder()
executes after notifyDataSetChanged()
.
Code on mute/unmute icon's click
case R.id.volume_button:
if (isToPlaySoundInitially) {
volumeKey.setImageResource(R.drawable.unmute_video);
isToPlaySoundInitially = false;
mVideoView.unMuteVideo();
} else {
volumeKey.setImageResource(R.drawable.mute_video);
isToPlaySoundInitially = true;
mVideoView.muteVideo();
}
notifyDataSetChanged();
break;
Method to mute/unmute sound
public void muteVideo() {
if (this.mp != null) {
mp.setVolume(0, 0);
}
}
public void unMuteVideo() {
if (this.mp != null) {
mp.setVolume(1, 1);
}
}
Please suggest how can I mute/unmute sound for all items of the list.
Thank You.