stop sound playing||doc135616

September 20, 2022

Format

 TdAudioEngine:stopSound(nSoundId)

Description

Stop playing the sound effect corresponding to the sound effect ID.


Precautions

To stop the playback 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. And, in order to determine whether the sound has stopped, callisPlayingCheck the return value.


Parameters

Variable name type Description
nSoundId int sound effectId


Code Samples

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