我在 CreateJS 套件中使用 SoundJS 库。我使用 LoadQueue 类来预加载我所有的声音。我发现当我第一次播放声音效果时,它在播放前延迟了半秒。在第一次播放之后,它将完美播放。
如果您一分钟左右不播放任何声音,该问题也会再次出现。然后播放声音效果将在第一次播放时有延迟。
知道为什么吗?有没有办法解决这个问题?(即以 0% 的音量播放背景音乐。
这是我的代码(使用打字稿):
import ReelStop from "../sound/reelstop.mp3";
private queue = new createjs.LoadQueue();
this.queue.installPlugin(createjs.Sound);
this.queue.on("complete", this.handleComplete, this);
this.queue.addEventListener("progress", this.onProgress);
this.queue.loadManifest([
// other sounds and images
{id: "reelStop", src: ReelStop},
]);
// after the preload complete has fired, the first time the sound is played there is that 500ms+ delay :
const reelStop= createjs.Sound.play("reelStop");
reelStop.volume = 0.5;
Thanks in advance for any ideas you may have