Jump to content

Sound not stopping right away when playing it simultaneously


mwatt
 Share

Recommended Posts

Hi all,

 

I've got a scenario where I am using a sound more than once and sometimes simultaneously.  It gets invoked from a timer call back.  The sound object is stored globally.

 

My problem, as alluded to in the title, is that if I only play one of these sounds it will stop immediately if I call stop() on it.  However, if I play more than one at time, there is a bit of a delay before it stops.  I have tried renaming the sound in order to use different file names and sound objects for my simultaneous sounds.  This does not seem to make any difference.

 

I am thinking it might be related to a timer usage bug (timer id also stored globally).  I've tried scenarios with both setInterval/clearInterval and setTimeout/clearTimeout.  The behavior seems to persist whatever I do.

 

I have logged to the console when I do things like start sound, stop sound, start timer and stop timer.  All of these seem to be happening when they should, and yet the lag on stopping the sound persists in the scenario where I had more than one going at a time.  This lag seems to have a slight variance, lending some credence to the possibility of a timer issue.

 

The reason I am making this post is that I'd like to know if anyone else has seen a similar issue with the Phaser sound implementation.   I'm going to keep looking into this from the perspective of my code, but I don't want to be knocking my head into a brick wall if there is some known issue that I would have no control of.

Link to comment
Share on other sites

I haven't done anything with Phaser sound yet beyond playing the simplest of sounds once. Caveat poster.

 

Do you think it'd be useful to try writing the WebAudio code directly to see if its browser-related vs. Phaser-related? You could use a library like howler.js to test it out, too. That way you'd know where to focus your efforts when looking for a solution?

Link to comment
Share on other sites

That's not a bad idea.  It does involve a fair amount of extra work that I probably won't end up using though.  I'd still like other inputs on this question, of there are any to be had, but I will say that I have worked around this within my game, at least at this point.  I would like to have the option to remove the work around though, which basically is to minimize the need for these sounds to play simultaneously.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...