sound.js icon indicating copy to clipboard operation
sound.js copied to clipboard

Pause/Resume while maintaining an accurate song time?

Open CloverFeywilde opened this issue 8 years ago • 0 comments

Trying to use this for implementation in my rhythm game, but the way this is written makes it very difficult to implement a pause feature for my game.

Everything in my game depends on me knowing at all times an accurate number for the song's current playback time. In a resolved issue someone pointed out that I could use:

sounds['src'].soundNode.context.currentTime - sounds['src'].startTime

This works like a charm.... until the song gets paused. As soon as the song is resumed, sounds['src'].startTime jumps up to equal sounds['src'].soundNode.context.currentTime and the whole thing just becomes a mess to keep track of.

Can anyone help me come up with a way that I can pause the song, and when it's resumed, still maintain an accurate song play time?

CloverFeywilde avatar Oct 12 '17 20:10 CloverFeywilde