feat(player): set right ctrl vol max to mpv's vol max if player==local (#2198)

This commit is contained in:
Simon Slamka
2026-07-16 08:43:43 +03:00
committed by GitHub
parent 5e79e385d9
commit ddd45ad5ba
9 changed files with 106 additions and 21 deletions
@@ -32,6 +32,7 @@ import {
useSettingsStoreActions,
useSidebarRightExpanded,
useSideQueueType,
useVolumeMax,
useVolumeWheelStep,
useVolumeWidth,
} from '/@/renderer/store';
@@ -56,11 +57,11 @@ import { useThrottledValue } from '/@/shared/hooks/use-throttled-value';
import { LibraryItem, QueueSong, ServerType } from '/@/shared/types/domain-types';
import { PlayerType } from '/@/shared/types/types';
const calculateVolumeUp = (volume: number, volumeWheelStep: number) => {
const calculateVolumeUp = (volume: number, volumeWheelStep: number, volumeMax: number) => {
let volumeToSet: number;
const newVolumeGreaterThanHundred = volume + volumeWheelStep > 100;
if (newVolumeGreaterThanHundred) {
volumeToSet = 100;
const newVolumeGreaterThanMax = volume + volumeWheelStep > volumeMax;
if (newVolumeGreaterThanMax) {
volumeToSet = volumeMax;
} else {
volumeToSet = volume + volumeWheelStep;
}
@@ -508,6 +509,7 @@ const VolumeButton = () => {
const muted = usePlayerMuted();
const volumeWheelStep = useVolumeWheelStep();
const volumeWidth = useVolumeWidth();
const volumeMax = useVolumeMax();
const { decreaseVolume, increaseVolume, mediaToggleMute, setVolume } = usePlayer();
const isMinWidth = useMediaQuery('(max-width: 480px)');
@@ -569,12 +571,12 @@ const VolumeButton = () => {
if (e.deltaY > 0 || e.deltaX > 0) {
volumeToSet = calculateVolumeDown(volume, volumeWheelStep);
} else {
volumeToSet = calculateVolumeUp(volume, volumeWheelStep);
volumeToSet = calculateVolumeUp(volume, volumeWheelStep, volumeMax);
}
setVolume(volumeToSet);
},
[setVolume, volume, volumeWheelStep],
[setVolume, volume, volumeWheelStep, volumeMax],
);
const handleVolumeDownThrottled = useThrottledCallback(handleVolumeDown, 100);
@@ -638,7 +640,7 @@ const VolumeButton = () => {
</ContextMenu>
{!isMinWidth ? (
<CustomPlayerbarSlider
max={100}
max={volumeMax}
min={0}
onChange={handleVolumeSlider}
onClick={(e) => {