Set the volume of the sound effect||doc135617

September 20, 2022

Format

 TdAudioEngine:setSoundsVolume(nSoundId, volume) 

Description

Set the volume of the sound effect corresponding to the sound effect Id.


Precautions

To set the volume of the sound effect, you must first obtain the id number of the sound effect to be set. So this function should be matched with the playback function of the sound effectplay3dSoundorplay2dSoundto use. Finally, we can callgetSoundsVolumeto return the set volume value.


Parameters

Variable name type Description
nSoundId int sound effectId
volume float volume value


Code Samples

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