类型 函数 库 audio.* 返回值 无 修订 版本 2024.3703 关键词 audio, dispose 另请参阅 audio.loadSound() audio.loadStream()
释放与句柄关联的音频内存。
内存释放后,不得再使用该句柄。尝试释放音频时,该音频不应处于活动状态
audio.dispose( audioHandle )
audio.loadSound() 和 audio.loadStream() 返回的要释放的句柄。
-- Load a laser sound and a background music stream into memory local laserSound = audio.loadSound( "laserSound.wav" ) local backgroundMusic = audio.loadStream( "backgroundMusic.m4a" ) -- Play both the sound and the stream local playLaserSound = audio.play( laserSound ) local playBackgroundMusic = audio.play( backgroundMusic ) -- Stop both the sound and the stream and 'nil' out each reference audio.stop( playLaserSound ) playLaserSound = nil audio.stop( playBackgroundMusic ) playBackgroundMusic = nil -- Dispose the handles from memory and 'nil' out each reference audio.dispose( laserSound ) audio.dispose( backgroundMusic ) laserSound = nil --prevents the handle from being used again backgroundMusic = nil --prevents the handle from being used again