goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
23.29k stars 2.21k forks source link

How to differentiate between a sound already played or about to be played based on soundID params? #1709

Open bundely opened 4 months ago

bundely commented 4 months ago

The Problem

We currently on our games are pausing all sounds when user switches tab from game to other browser tabs. We unpause the sounds based on sound ID properties like sound._ended is false && sound._playStart is not undefined sound._paused is true.

For example 'onRevealLast' audiohook command has 5 nested commands. Right when 2 audios were playing we switching the tabs but now I am not able to play last one - sl_VannaPrompt because this soundID's properties like sound._ended is true since it never played in first place. Is there a property which can differentiate between a played sound ID and unplayed fresh soundID?

"onRevealLast":[{"command":"Play","spriteId":"s_LastPointerAwarded_FP"}, {"command":"Stop","spriteId":"s_PickerMusicLoop"},{"command":"Stop","spriteId":"s_OnePickLeft_FP","delay":7802},{"command":"Play","spriteId":"s_DrumRollAloneLoop","loop":-1,"delay":7802},{"command":"Play","spriteId":"s_Bonus2MusicLoop","loop":-1,"delay":8259},{"command":"Play","spriteListId":"sl_VannaPrompt","delay":8259}],

Reproducible Example

No response

Reproduction Steps

Check for multiple soundIDs under one howlInstance. Sound ID parameters of sound id played and completed are same as sound id which has not begun playing yet.

Possible Solution

If we have sound properties that would differentiate between played and unplayed sound ID then it would make it easier to differentiate.

Context

No response

Howler.js Version

2.2.3

Affected Browser(s)/Versiuon(s)

chrome, safari