Set sound playback speed||doc135624

September 20, 2022

Format

 TdAudioEngine:setSoundSpeed(nSoundId, percentage)

Description

Set the playback speed of the sound effect corresponding to the sound effect Id, expressed as a percentage.


Precautions

To set the playback speed of a sound effect, you must first obtain the id number of the sound effect. This function should be matched with the playback function of the sound effectplay3dSoundorplay2dSoundto use.


Parameters

Variable name type Description
nSoundId int sound effect id
percentage float percentage


Code Samples

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