Skip to content

Commit

Permalink
Merge pull request #1 from darkpixlz/albumres
Browse files Browse the repository at this point in the history
merge album resolution stuff
  • Loading branch information
iiPythonx authored Feb 8, 2024
2 parents 73c6ddd + 439bbb6 commit 4d4ee1b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@
"playButtonBehavior_optionAddLast": "$t(player.addLast)",
"playButtonBehavior_optionAddNext": "$t(player.addNext)",
"playButtonBehavior_optionPlay": "$t(player.play)",
"playerAlbumArtResolution": "Player Album Art Resolution",
"playerAlbumArtResolution_description": "The resolution for the large player's album art preview. Larger makes it look more crisp, but may slow loading down. Defaults to 0, meaning auto",
"remotePassword": "remote control server password",
"remotePassword_description": "sets the password for the remote control server. These credentials are by default transferred insecurely, so you should use a unique password that you do not care about",
"remotePort": "remote control server port",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
usePlayerData,
usePlayerStore,
} from '/@/renderer/store';
import { useSettingsStore } from '/@/renderer/store/settings.store';

const Image = styled(motion.img)<{ $useAspectRatio: boolean }>`
position: absolute;
Expand Down Expand Up @@ -130,6 +131,8 @@ export const FullScreenPlayerImage = () => {
const mainImageRef = useRef<HTMLImageElement | null>(null);
const [mainImageDimensions, setMainImageDimensions] = useState({ idealSize: 1 });

const albumArtRes = useSettingsStore((store) => store.general.albumArtRes);

const { queue } = usePlayerData();
const { opacity, useImageAspectRatio } = useFullScreenPlayerStore();
const currentSong = queue.current;
Expand All @@ -149,6 +152,7 @@ export const FullScreenPlayerImage = () => {
if (mainImageRef.current) {
setMainImageDimensions({
idealSize:
albumArtRes ||
Math.ceil((mainImageRef.current as HTMLDivElement).offsetHeight / 100) * 100,
});

Expand All @@ -158,7 +162,7 @@ export const FullScreenPlayerImage = () => {
topImage: scaleImageUrl(mainImageDimensions.idealSize, queue.current?.imageUrl),
});
}
}, [mainImageDimensions.idealSize, queue, setImageState]);
}, [mainImageDimensions.idealSize, queue, setImageState, albumArtRes]);

useLayoutEffect(() => {
updateImageSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ export const ControlSettings = () => {
isHidden: false,
title: t('setting.buttonSize', { postProcess: 'sentenceCase' }),
},
{
control: (
<NumberInput
defaultValue={settings.albumArtRes || undefined}
max={2500}
min={175}
placeholder="0"
rightSection="px"
width={75}
onBlur={(e) => {
const newVal = e.currentTarget.value
? Math.min(Math.max(Number(e.currentTarget.value), 175), 2500)
: null;
setSettings({ general: { ...settings, albumArtRes: newVal } });
}}
/>
),
description: t('setting.playerAlbumArtResolution', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: false,
title: t('setting.playerAlbumArtResolution', { postProcess: 'sentenceCase' }),
},
{
control: (
<Switch
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/store/settings.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export interface SettingsState {
};
general: {
accent: string;
albumArtRes?: number | null;
buttonSize: number;
defaultFullPlaylist: boolean;
externalLinks: boolean;
Expand Down Expand Up @@ -283,6 +284,7 @@ const initialState: SettingsState = {
},
general: {
accent: 'rgb(53, 116, 252)',
albumArtRes: undefined,
buttonSize: 20,
defaultFullPlaylist: true,
externalLinks: true,
Expand Down

0 comments on commit 4d4ee1b

Please sign in to comment.