Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iwasrobbed opened this issue Feb 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@iwasrobbed
Copy link

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

MEDIA_MUTE_REQUEST: (media) => (media.muted = true),
MEDIA_UNMUTE_REQUEST: (media) => {
media.muted = false;
// Avoid confusion by bumping the volume on unmute
if (media.volume === 0) {
media.volume = 0.25;
}
},
MEDIA_VOLUME_REQUEST: (media, event, mediaController) => {
const volume = event.detail;
media.volume = volume;
// If the viewer moves the volume we should unmute for them.
if (volume > 0 && media.muted) {
media.muted = false;
}
// don't set to localStorage if novolumepref attribute is set
if (!mediaController.hasAttribute('novolumepref')) {
// Store the last set volume as a local preference, if ls is supported
try {
globalThis.localStorage.setItem(
'media-chrome-pref-volume',
volume.toString()
);
} catch (err) {
// ignore
}

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
Copy link
Collaborator

@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.

@luwes luwes added the bug Something isn't working label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants