Sound effect delayed after first time it's played

118 Views Asked by At

I am using the SoundJS library within the CreateJS suite. I use the LoadQueue class to preload all my sounds. I am finding that when I go to play a sound effect for the first time it's delayed by a good half second before it plays. After the first play, it will play perfectly after that.

The problem also re-occurrs if you don't play any sounds for a minute or so. Then playing a sound effect will have that delay on first play.

Any idea why? Is there a work around to fix the issue? (ie. playing background music at 0% volume.

Here is my code (using typescript) :

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


0

There are 0 best solutions below