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

Make the volume slider less silly #2681

Open
wants to merge 1 commit into
base: livekit
Choose a base branch
from

Conversation

robintown
Copy link
Member

Previously, dragging it all the way to the left would not mute the participant but rather bottom out at 10% volume, and people have found this unintuitive. Let's make it less silly by giving the slider a range of 0% to 100%, and making the mute toggle button have the same effect as dragging the slider to zero. When unmuting, it will reset to the last non-zero "committed" volume, similar to how the volume sliders in desktop environments work.

Previously, dragging it all the way to the left would *not* mute the participant but rather bottom out at 10% volume, and people have found this unintuitive. Let's make it less silly by giving the slider a range of 0% to 100%, and making the mute toggle button have the same effect as dragging the slider to zero. When unmuting, it will reset to the last non-zero "committed" volume, similar to how the volume sliders in desktop environments work.
Comment on lines +253 to +265
(state, event) =>
event === "toggle mute"
? { ...state, muted: !state.muted }
: event === "commit"
? { ...state, committedVolume: state.volume }
: // Volume adjustment
event === 0
? // Dragging the slider to zero should have the same effect as
// muting: reset the volume to the committed volume, as if it were
// never dragged
{ ...state, muted: true, volume: state.committedVolume }
: { ...state, muted: false, volume: event },
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO using a switch statement reads better:

Suggested change
(state, event) =>
event === "toggle mute"
? { ...state, muted: !state.muted }
: event === "commit"
? { ...state, committedVolume: state.volume }
: // Volume adjustment
event === 0
? // Dragging the slider to zero should have the same effect as
// muting: reset the volume to the committed volume, as if it were
// never dragged
{ ...state, muted: true, volume: state.committedVolume }
: { ...state, muted: false, volume: event },
),
(state, event) => {
switch (event) {
case "toggle mute":
return { ...state, muted: !state.muted };
case "commit":
return { ...state, committedVolume: state.volume };
case 0: // Volume adjustment
// Dragging the slider to zero should have the same effect as
// muting: reset the volume to the committed volume, as if it were
// never dragged
return { ...state, muted: true, volume: state.committedVolume };
default:
return { ...state, muted: false, volume: event };
}
}),

Comment on lines 33 to +34
onValueChange: onValueChangeProp,
onValueCommit: onValueCommitProp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOI where are onValueChangeProp & onValueCommit prop defined?

@@ -16,6 +16,7 @@ interface Props {
label: string;
value: number;
onValueChange: (value: number) => void;
onValueCommit?: (value: number) => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be optional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants