You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(sound): set or read the mute state, control music playback, overlap sounds #520
Which package or utils is this feature request for?
sound
Feature
The sound and music libraries are too small for the example games (NanoForge-dev/examples#18), which each work around them:
Mute is a toggle only, and both libraries start muted (sound.library.ts#L17, music.library.ts#L17). A game can't set "muted" or "unmuted", or read the current state, so it must count its own mute() calls (basics/sound, basics/music, the arcade games' loadSounds).
Music has no pause, stop, resume, loop or volume.play pauses the current track but doesn't rewind it (music.library.ts#L61): playing a track again resumes it from where it stopped, and a track ends instead of looping.
One audio element per sound key: playing a sound while it is still playing does nothing, so quick repeats (shots, hits) are dropped.
Ideal solution or implementation
setMuted(muted: boolean) and isMuted() on both libraries, keeping mute() as the toggle.
Music: pause(), resume(), stop() (rewinds), a loop option on load or play, and a volume.
Sound: let a sound overlap itself (a small pool of elements per key, or Web Audio buffers).
Alternative solutions or implementations
No response
Other context
Related: #510 (the READMEs don't say that sound and music start muted) and #505 (loading a key again leaks the old element).
Activity