muxinc / media-chrome

Custom elements (web components) for making audio and video player controls that look great in your website or app.
https://media-chrome.org
MIT License
1.77k stars 71 forks source link

Volume pref. not persisted for mute / unmute, so inconsistent volume level stored in local storage #803

Open iwasrobbed opened 9 months ago

iwasrobbed commented 9 months ago

Issue

Currently, the volume level is only persisted if you manually drag the volume slider, but does not persist if you mute/unmute so this leads to an inconsistent state where the persisted volume level does not match the volume slider's value.

See https://github.com/muxinc/media-chrome/blob/daa4b406fdf8c875fe4dcbffe342ca9bab99733f/src/js/controller.js#L569-L598

Repro

  1. Slide the volume slider all the way to zero and notice the media-chrome-pref-volume in local storage changes to 0 eventually as well
  2. Tap the unmute icon and notice the volume slider is no longer set to 0
  3. Look at the media-chrome-pref-volume key in local storage and notice it's still 0
  4. Reload the player and see that the preferred volume is still muted even though the last time we unmuted it

Expected Behavior

Muting / unmuting should also update media-chrome-pref-volume in local storage, e.g. the volume slider changed value should always be persisted, regardless of which button (such as mute) is changing the volume.

cjpillsbury commented 9 months ago

@iwasrobbed good callout! I think your intuition here is the right one for expected behavior. We'll try to get around to this ASAP, but we're also open to contributions if you'd like to knock it out. Sounds like you have a decent understanding of the codebase.