mute all||doc135622

September 20, 2022

Format

 TdAudioEngine:allMute(isMute) 

Description

All volumes are set to 0, one-key mute.


Precautions

To set all sound effects to mute, first get the id number of a sound effect. This function should be matched with the playback function of the sound effectplay3dSoundorplay2dSoundto use. Then, bygetSoundsVolumeTo get the volume of the sound effect, set the global mute, and then get the volume of the sound effect to determine whether it has been set to mute.


Parameters

Variable name type Description
isMute boolean Whether to mute all


Code Samples

local TdAudioEngine = TdAudioEngine.Instance()
local soundID = TdAudioEngine:play2dSound("asset/Audio/Sound/click.mp3", true)
print(TdAudioEngine:getSoundsVolume(soundID))
TdAudioEngine:allMute(true)
print(TdAudioEngine:getSoundsVolume(soundID))
end