Get sound volume||doc135618

September 20, 2022

Format

 TdAudioEngine:getSoundsVolume(nSoundId)

Description

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


Precautions

To get the volume of the sound effect, you must first get the id number of the sound effect. So this function should be matched with the playback function of the sound effectplay3dSoundorplay2dSoundto use.


Parameters

Variable name type Description
nSoundId int sound effect id

Value Returned

type Description
float return volume


Code Samples

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