News for hackers. Stuff that matters.
Re:Show HN: Ambiphone, no-nonsense ambient music and white n... by hunter2_ on Wednesday January 03, 2024 @01:55PM (#38858119)
You could store all state in the URL fragment. Maybe each key is a sound and each value is the volume, like /#whale=5&fire=8 or whatever. Call replaceState (better than pushState to avoid polluting the back button history with every little tweak) whenever the user changes something. On page load, read from the URL fragment using window.location.hash and then sharing is just a matter of copying the URL, which could be done entirely in browser chrome, and/or via a "share" button you provide.

These might help:

https://www.jvt.me/posts/2019/08/01/node-parse-url-fragment/

https://stackoverflow.com/a/66416539

Re:Show HN: Ambiphone, no-nonsense ambient music and white n... by matteason on Wednesday January 03, 2024 @02:08PM (#38858342)
This is exactly what I do on https://www.matteason.co.uk/scotbeats/ actually - any settings change is reflected in the URL and read back on load. When I implement sharing of individual mixes it'll probably look a lot like this
Re:Show HN: Ambiphone, no-nonsense ambient music and white n... by catapart on Wednesday January 03, 2024 @02:01PM (#38858218)
Great recommendation for such simple state! The portability of that is just perfect!