Skip to content

Commit

Permalink
Improve visualizer settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rekkyrosso committed Dec 21, 2024
1 parent a85051f commit 0361324
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async function checkForUpdatesAndNotify() {

app.whenReady().then(async () => {
const mainWindowState = windowStateKeeper({
defaultWidth: 1024,
defaultWidth: 1200,
defaultHeight: 768,
});
const splash = await createSplashScreen(mainWindowState);
Expand All @@ -187,8 +187,8 @@ app.whenReady().then(async () => {
createBridge();

await createMainWindow(url, mainWindowState);
await checkForUpdatesAndNotify();
splash.close();
await checkForUpdatesAndNotify();

// For mac apparently.
app.on('activate', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@
font-size: 0.75em;
vertical-align: middle;
}

.note {
font-size: 0.875em;
text-align: center;

p:last-child {
margin-top: 1em;
}
}
}
32 changes: 22 additions & 10 deletions src/components/Settings/VisualizerSettings/VisualizerRandomness.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import React, {useCallback, useEffect, useId, useRef, useState} from 'react';
import React, {useCallback, useEffect, useId, useMemo, useRef, useState} from 'react';
import VisualizerProviderId from 'types/VisualizerProviderId';
import {getService} from 'services/mediaServices';
import {getCurrentItem} from 'services/playlist';
import {isSourceVisible} from 'services/mediaServices/servicesSettings';
import visualizerSettings from 'services/visualizer/visualizerSettings';
import ExternalLink from 'components/ExternalLink';
import useVisualizerRandomness, {Weighting} from './useVisualizerRandomness';
import './VisualizerRandomness.scss';

export default function VisualizerRandomness() {
const id = useId();
const spotify = getService('spotify');
const hasSpotify = spotify && visualizerSettings.spotifyEnabled && isSourceVisible(spotify);
const hasSpotify = spotify && isSourceVisible(spotify);
const refSpotify = useRef<HTMLInputElement>(null);
const [isSpotify, setIsSpotify] = useState(false);
const isSpotifyItem = useMemo(() => getCurrentItem()?.src.startsWith('spotify:'), []);
const [isSpotify, setIsSpotify] = useState(isSpotifyItem);
const {standardWeightings, spotifyWeightings} = useVisualizerRandomness();

const handleRandomnessChange = useCallback((weightings: readonly Weighting[]) => {
Expand Down Expand Up @@ -44,7 +47,7 @@ export default function VisualizerRandomness() {
id={`${id}-view-standard`}
name="weighting-view"
type="radio"
defaultChecked={true}
defaultChecked={!isSpotifyItem}
onChange={handleSpotifyChange}
/>
<label htmlFor={`${id}-view-standard`}>Standard</label>
Expand All @@ -54,7 +57,7 @@ export default function VisualizerRandomness() {
id={`${id}-view-spotify`}
name="weighting-view"
type="radio"
defaultChecked={false}
defaultChecked={isSpotifyItem}
onChange={handleSpotifyChange}
ref={refSpotify}
/>
Expand All @@ -67,11 +70,20 @@ export default function VisualizerRandomness() {
hidden={isSpotify}
onChange={handleRandomnessChange}
/>
<VisualizerWeightings
weightings={spotifyWeightings}
hidden={!isSpotify}
onChange={handleSpotifyRandomnessChange}
/>
{visualizerSettings.spotifyEnabled ? (
<VisualizerWeightings
weightings={spotifyWeightings}
hidden={!isSpotify}
onChange={handleSpotifyRandomnessChange}
/>
) : (
<div className="weightings note" hidden={!isSpotify}>
<p>Spotify visualizers are only supported on the web app.</p>
<p>
<ExternalLink href="https://ampcast.app" />
</p>
</div>
)}
</fieldset>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Splitter/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#media-library-layout {
& > .layout-pane-1 {
min-width: calc(3rem + 2 * var(--gutter-width));
flex-basis: 17%;
flex-basis: 22%;
}

& > .layout-pane-2 {
Expand Down
9 changes: 2 additions & 7 deletions src/services/visualizer/visualizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ import butterchurn from './butterchurn';
import coverart from './coverart';
import spotifyviz from './spotifyviz';
import waveform from './waveform';
import visualizerSettings from './visualizerSettings';

const visualizers: VisualizerProvider[] = [
ambientvideo,
ampshader,
audiomotion,
butterchurn,
coverart,
spotifyviz,
waveform
];

if (visualizerSettings.spotifyEnabled) {
visualizers.push(spotifyviz);
}

visualizers.push(waveform);

export default visualizers;

0 comments on commit 0361324

Please sign in to comment.