mirror of
https://github.com/jeffvli/feishin.git
synced 2026-08-08 05:12:57 +02:00
feat(player): set right ctrl vol max to mpv's vol max if player==local (#2198)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user