Skip to content

Commit

Permalink
Make volume props optional
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Apr 14, 2024
1 parent a90219d commit d6e437e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions web/src/components/player/VideoControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ type VideoControlsProps = {
features?: VideoControls;
isPlaying: boolean;
show: boolean;
muted: boolean;
volume: number;
muted?: boolean;
volume?: number;
controlsOpen?: boolean;
playbackRates?: number[];
playbackRate: number;
hotKeys?: boolean;
setControlsOpen?: (open: boolean) => void;
setMuted: (muted: boolean) => void;
setMuted?: (muted: boolean) => void;
onPlayPause: (play: boolean) => void;
onSeek: (diff: number) => void;
onSetPlaybackRate: (rate: number) => void;
Expand Down Expand Up @@ -95,7 +95,7 @@ export default function VideoControls({
// volume control

const VolumeIcon = useMemo(() => {
if (volume == 0.0 || muted) {
if (!volume || volume == 0.0 || muted) {
return MdVolumeOff;
} else if (volume <= 0.33) {
return MdVolumeMute;
Expand All @@ -122,7 +122,7 @@ export default function VideoControls({
}
break;
case "m":
if (down && !repeat && video) {
if (setMuted && down && !repeat && video) {
setMuted(!muted);
}
break;
Expand Down Expand Up @@ -156,13 +156,16 @@ export default function VideoControls({
className="size-5"
onClick={(e: React.MouseEvent) => {
e.stopPropagation();
setMuted(!muted);

if (setMuted) {
setMuted(!muted);
}
}}
/>
{muted == false && (
<VolumeSlider
className="w-20"
value={[volume]}
value={[volume ?? 1.0]}
min={0}
max={1}
step={0.02}
Expand Down

0 comments on commit d6e437e

Please sign in to comment.