Pause sound playback||doc135620

September 20, 2022

Format

 TdAudioEngine:pauseSound(nSoundId) 

Description

Pause the playback of the sound effect corresponding to the sound effect ID.


Precautions

To pause the playback of a sound effect, you must first obtain the id number of the sound effect. So this function should be matched with the playback function of the sound effectplay3dSoundorplay2dSoundto use. And, in order to determine whether the sound has been paused, 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:pauseSound(soundID)
print(TdAudioEngine:isPlaying(soundID))
end