CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

Mobile Chrome sound play lag. #252

Closed devMikeG closed 6 years ago

devMikeG commented 7 years ago

It seems that there is a slight lag every time I try to play a sound on mobile chrome. The audio file has no silence at the start. I am preloading the sound. This only happens on Chrome, it also happens when I completely bypass SoundJS (and use HTML Audio), so I'm confident that SoundJS isn't actually the culprit here, but I'm wondering if you guys have seent this issue before and could possibly suggest a workaround?

Any help appreciated. My code is below:

Kind regards

Mike

playOneShotAudio("LeadNote1", 1);

function playOneShotAudio(sSoundID, fVolume) {
    var oPlayProperties = {
            interrupt: createjs.Sound.INTERRUPT_NONE,
            delay: 0,
            offset: 0,
            loop: 0, // single shot sound
            volume: fVolume
        },
        oSound = createjs.Sound.play(sSoundID, oPlayProperties);
    return oSound;
}
lannymcnie commented 7 years ago

Any chance you are playing the audio on click? Mobile browsers have an intentional click delay that may make it seem like there is a short pause (300ms) before the sound.

devMikeG commented 7 years ago

Hi Lanny, actually no, I used a few diifferent handlers to test that a while back, makes no difference. In researching this further it's actually Android's terrible audio engine and the latency it produces. It's a known problem that has been 'getting better' with each new release of Android.

lannymcnie commented 6 years ago

Closing, unless there is something else we can do with this. Feel free to reopen with more information.