shuttlecraft icon indicating copy to clipboard operation
shuttlecraft copied to clipboard

Add a beep sound

Open ringtailsoftware opened this issue 2 years ago • 5 comments

CC0 licensed, no attribution needed, https://opengameart.org/content/8-bit-sound-effect-pack

ringtailsoftware avatar Dec 27 '22 10:12 ringtailsoftware

Alas, in Chrome, this throws an error instead of playing the sound.

"app.js:45 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD"

benbrown avatar Jan 03 '23 03:01 benbrown

Huh! It seems to be working after some small tweaks.

benbrown avatar Jan 03 '23 03:01 benbrown

A few things to do before this merges:

  • [ ] put the sound at a normal url like public/beep.mp4 or whatever it is (make it easier for people to change, find, etc)
  • [ ] sound currently fires every page load. should only fire when the number changes. tricky.

benbrown avatar Jan 03 '23 03:01 benbrown

Changed to use /audio/beep.wav AIUI, the beep sound does not play on every page load as app.newDMs will be undefined, https://github.com/benbrown/shuttlecraft/blob/main/public/app.js#L90

ringtailsoftware avatar Jan 03 '23 12:01 ringtailsoftware

app.newDMs should be initialized to 0, not doing so was a bug. Any of the other counters could also immediately return with a number and cause the beep to fire, and as implemented could cause multi-beeps!

Just thinking out loud here but I think to get this right I need to:

  • improve the implementation and generalize the availability of the notification indicators
  • perhaps render them serverside and initialize with real current values
  • make the client side code a bit more sophisticated about when to beep

benbrown avatar Jan 03 '23 16:01 benbrown