更新时间:2021-07-28 20:57:58
向您的MediaPlayerPool
类添加变量,我们将其称为mute
Add a variable to your MediaPlayerPool
class, let's call it mute
public boolean mute = false;
具有一个静音/取消静音按钮,并在其onClick
方法上(将切换):
Have a mute/unmute button and on its onClick
method (will toggle):
MediaPlayerPool.getInstance().mute = !MediaPlayerPool.getInstance().mute
,您的playSound
方法变为
public void playSound(int soundId) {
if(!mute) {
// stick your current code here
}
}