feat(web): the volume control in the player bar and the full-screen player

Both places move the same volume. README mentions it.
This commit is contained in:
tgiachi 2026-11-12 15:23:50 +01:00
commit 99d25acd9a
4 changed files with 19 additions and 2 deletions

View file

@ -328,7 +328,7 @@ npm install
SONDA_URL=http://127.0.0.1:8080 npm run dev # open http://localhost:5173, /api is proxied to Sonda
```
What it does today: sign in (and create the first account of a new server), browse artists, albums and songs, search, and play with a queue, shuffle, repeat, media keys and a full-screen player. Artist pages show the Wikipedia text, similar artists and tags when those providers are on, each with its credit, and the photo credit next to the photo. It reports one listen per play. Discover suggests artists from the ones you pick, or from your listening only after you allow it (a dialog says that their names go to Last.fm), explains each score, and keeps your wishlist and the artists you are not interested in. An admin who set up the `lidarr` provider gets a "Request on Lidarr" button on an artist's page and on the Discover cards: it asks first, then sends that one artist to their own Lidarr, which does the downloading (the web app downloads nothing; the page of an artist reads what Lidarr has, the cards ask nothing until you send). An admin also gets an Admin area to add, rename, move and remove libraries and to start a scan (of one library or all, optionally reading every file again) and follow it, and to manage accounts: add one by email, give or take away the admin role, reset a password (which ends that person's sessions) and delete an account. The last admin cannot be changed, and your own account has no buttons there. Providers have a card each that says what the provider is sent: turning one on asks first, the API key is write-only (never shown, and gone from the page once saved), and there are a test of the key, the contact or address, removing what a provider gave, and, for Lidarr, the profiles and root folder to use when an artist is added. There are six themes (Sonda, Tokyo Night, Gruvbox dark, Gruvbox light, Dracula and Neon) and two languages (English and Italian), both chosen in Settings.
What it does today: sign in (and create the first account of a new server), browse artists, albums and songs, search, and play with a queue, shuffle, repeat, media keys, a volume slider with mute (remembered in the browser) and a full-screen player. Artist pages show the Wikipedia text, similar artists and tags when those providers are on, each with its credit, and the photo credit next to the photo. It reports one listen per play. Discover suggests artists from the ones you pick, or from your listening only after you allow it (a dialog says that their names go to Last.fm), explains each score, and keeps your wishlist and the artists you are not interested in. An admin who set up the `lidarr` provider gets a "Request on Lidarr" button on an artist's page and on the Discover cards: it asks first, then sends that one artist to their own Lidarr, which does the downloading (the web app downloads nothing; the page of an artist reads what Lidarr has, the cards ask nothing until you send). An admin also gets an Admin area to add, rename, move and remove libraries and to start a scan (of one library or all, optionally reading every file again) and follow it, and to manage accounts: add one by email, give or take away the admin role, reset a password (which ends that person's sessions) and delete an account. The last admin cannot be changed, and your own account has no buttons there. Providers have a card each that says what the provider is sent: turning one on asks first, the API key is write-only (never shown, and gone from the page once saved), and there are a test of the key, the contact or address, removing what a provider gave, and, for Lidarr, the profiles and root folder to use when an artist is added. There are six themes (Sonda, Tokyo Night, Gruvbox dark, Gruvbox light, Dracula and Neon) and two languages (English and Italian), both chosen in Settings.
More commands, all run in `web/`: `npm test`, `npm run build`, and `npm run gen:api`, which rebuilds `src/api/schema.d.ts` from the OpenAPI spec (it fetches the generator with `npx`, so it needs the network once). The bulk jobs screen and serving the app from the binary come later.

View file

@ -6,6 +6,7 @@ import Cover from '@/components/Cover'
import FullscreenButton from '@/components/FullscreenButton'
import Scrubber from '@/components/Scrubber'
import TrackRow from '@/components/TrackRow'
import VolumeControl from '@/components/VolumeControl'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@/components/ui/dialog'
import { formatTime } from '@/lib/time'
@ -92,6 +93,7 @@ export default function NowPlaying() {
</div>
<PlayerControls large />
<VolumeControl className="justify-center" />
{upNext.length > 0 && (
<section aria-label={t('player.upNext')} className="flex flex-col gap-1 border-t pt-4">

View file

@ -263,6 +263,19 @@ test('the bar and the full-screen player both have a button for browser full scr
}
})
test('the bar and the full-screen player both have a volume control, and they move the same volume', async () => {
usePlayer.setState({ volume: 0.5, muted: false })
act(() => usePlayer.getState().playTracks([a]))
renderBar()
expect(within(screen.getByRole('contentinfo')).getByRole('slider', { name: 'Volume' })).toHaveValue('50')
expect(screen.getByRole('button', { name: 'Mute' })).toBeInTheDocument()
const { dialog } = await openNowPlaying()
fireEvent.change(within(dialog).getByRole('slider', { name: 'Volume' }), { target: { value: '20' } })
expect(usePlayer.getState().volume).toBe(0.2)
await userEvent.click(within(dialog).getByRole('button', { name: 'Mute' }))
expect(usePlayer.getState().muted).toBe(true)
})
test('without the Fullscreen API neither the bar nor the full-screen player shows the button', async () => {
act(() => usePlayer.getState().playTracks([a]))
renderBar()

View file

@ -5,6 +5,7 @@ import { Link } from 'react-router-dom'
import Cover from '@/components/Cover'
import FullscreenButton from '@/components/FullscreenButton'
import Scrubber from '@/components/Scrubber'
import VolumeControl from '@/components/VolumeControl'
import { Button } from '@/components/ui/button'
import { formatTime } from '@/lib/time'
import { currentTrack, usePlayer } from '@/player/store'
@ -85,7 +86,8 @@ export default function PlayerBar() {
</div>
</div>
<div className="flex flex-[1_1_120px] justify-end">
<div className="flex flex-[1_1_120px] items-center justify-end">
<VolumeControl />
<FullscreenButton />
<Button
variant="ghost"