Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 32 additions & 37 deletions app/components/mini-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function MiniPlayer({
repeatLabel,
repeating,
onRepeat,
seek,
children,
}: {
label: string;
Expand All @@ -20,8 +21,6 @@ export function MiniPlayer({
title: string;
details: string;
href: string;
/** Names the page the artwork link opens. */
page: string;
artwork?: string;
};
controls?: boolean;
Expand All @@ -30,51 +29,47 @@ export function MiniPlayer({
repeatLabel: string;
repeating: boolean;
onRepeat: (repeat: boolean) => void;
seek?: ReactNode;
children?: ReactNode;
}) {
return (
<aside
className={className ? `release-mini ${className}` : "release-mini"}
aria-label={label}
>
{(controls || track?.artwork) && (
<div className="release-mini-transport">
{track?.artwork && (
<img src={track.artwork} alt="" width={52} height={52} />
)}
{controls && (
<IconButton
className="icon-action play-toggle"
icon={playing ? "pause" : "play"}
label={playing ? "Pause" : "Play"}
tooltip={playing ? "Pause (Space)" : "Play (Space)"}
aria-keyshortcuts="Space"
onClick={onToggle}
/>
)}
</div>
)}
{track && (
<>
<Link
to={track.href}
className="release-mini-artwork"
aria-label={`Open ${track.page}`}
>
{track.artwork ? (
<img src={track.artwork} alt="" width={52} height={52} />
) : (
<span aria-hidden="true">♫</span>
)}
</Link>
<div className="release-mini-description">
<Link to={track.href}>{track.title}</Link>
<span>{track.details}</span>
</div>
</>
<div className="release-mini-description">
<Link to={track.href}>{track.title}</Link>
<span>{track.details}</span>
</div>
)}
{seek}
{controls && (
<>
<IconButton
className="icon-action play-toggle"
icon={playing ? "pause" : "play"}
label={playing ? "Pause" : "Play"}
tooltip={playing ? "Pause (Space)" : "Play (Space)"}
aria-keyshortcuts="Space"
onClick={onToggle}
/>
<IconButton
className="icon-action"
icon="repeat"
label={repeatLabel}
tooltip={`${repeatLabel} ${repeating ? "on" : "off"}`}
aria-pressed={repeating}
onClick={() => onRepeat(!repeating)}
/>
</>
<IconButton
className="icon-action"
icon="repeat"
label={repeatLabel}
tooltip={`${repeatLabel} ${repeating ? "on" : "off"}`}
aria-pressed={repeating}
onClick={() => onRepeat(!repeating)}
/>
)}
{children}
</aside>
Expand Down
25 changes: 22 additions & 3 deletions app/components/release-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useMediaSession } from "./media-session";
import { setRepeatPreference, useRepeatPreference } from "./repeat-preference";
import { BufferedAudio } from "./buffered-audio";
import { MiniPlayer } from "./mini-player";
import { ReleaseSeek } from "./release-seek";
import { useSpaceToggle } from "./use-space-toggle";

const PlaybackContext = createContext<ReleasePlayback | null>(null);
Expand Down Expand Up @@ -39,8 +40,17 @@ export function ReleasePlayerProvider({ children }: { children: ReactNode }) {
}

function ReleasePlayer() {
const { playback, queue, index, status, error, seeking, media } =
useReleasePlayer();
const {
playback,
queue,
index,
status,
error,
seeking,
media,
position,
duration,
} = useReleasePlayer();
const repeat = useRepeatPreference();
useEffect(() => {
playback.setRepeat(repeat);
Expand Down Expand Up @@ -81,7 +91,6 @@ function ReleasePlayer() {
title: track.title,
details: track.artist,
href: queue.url,
page: queue.title,
artwork: queue.artwork?.src,
}
: undefined
Expand All @@ -91,6 +100,16 @@ function ReleasePlayer() {
repeatLabel="Repeat track"
repeating={repeat}
onRepeat={setRepeatPreference}
seek={
track && (
<ReleaseSeek
key={track.id}
position={position}
duration={duration}
onSeek={playback.seek}
/>
)
}
>
{track && (
<>
Expand Down
18 changes: 16 additions & 2 deletions app/components/release-seek.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import { formatClock } from "../domain/format";

export function ReleaseSeek({
Expand All @@ -13,6 +13,8 @@ export function ReleaseSeek({
const [preview, setPreview] = useState<number | null>(null);
const input = useRef<HTMLInputElement>(null);
const pending = useRef<number | null>(null);
const elapsedTime = formatClock(preview ?? position);
const totalTime = formatClock(duration);
function cancel() {
pending.current = null;
setPreview(null);
Expand Down Expand Up @@ -41,15 +43,27 @@ export function ReleaseSeek({
}, [onSeek]);
return (
<label className="release-seek">
{formatClock(preview ?? position)} / {formatClock(duration)}
<span
className="playback-time"
style={{ minWidth: `${totalTime.length * 2 + 3}ch` }}
>
{elapsedTime} / {totalTime}
</span>
<input
ref={input}
aria-label="Playback position"
aria-valuetext={`${elapsedTime} of ${totalTime}`}
type="range"
min={0}
max={duration || 1}
step={0.1}
value={preview ?? position}
disabled={!duration}
style={
{
"--seek-progress": `${duration ? Math.max(0, Math.min(100, ((preview ?? position) / duration) * 100)) : 0}%`,
} as CSSProperties
}
onChange={(event) => {
const next = event.currentTarget.valueAsNumber;
if (event.nativeEvent.type === "input") {
Expand Down
23 changes: 22 additions & 1 deletion app/components/workspace-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { type DemoPlayback } from "./demo-playback";
import { useMediaSession } from "./media-session";
import { setRepeatPreference, useRepeatPreference } from "./repeat-preference";
import { MiniPlayer } from "./mini-player";
import { ReleaseSeek } from "./release-seek";
import { useSpaceToggle } from "./use-space-toggle";

const WorkspaceAudio = createContext<WorkspacePlayback | null>(null);
Expand Down Expand Up @@ -59,6 +60,16 @@ function WorkspacePlayer({
playback.getSnapshot,
);
const repeat = useRepeatPreference();
const [position, setPosition] = useState(0);
useEffect(() => {
const remember = () => setPosition(media?.currentTime ?? 0);
const events = ["timeupdate", "seeked", "wavecase-user-seeked"];
remember();
for (const event of events) media?.addEventListener(event, remember);
return () => {
for (const event of events) media?.removeEventListener(event, remember);
};
}, [media]);
useEffect(() => {
playback.setRepeat(repeat);
}, [playback, repeat]);
Expand All @@ -74,6 +85,7 @@ function WorkspacePlayer({
return !!state.source || state.loading;
},
toggle,
slider: true,
});
useMediaSession(
media,
Expand Down Expand Up @@ -102,7 +114,6 @@ function WorkspacePlayer({
.filter(Boolean)
.join(" · "),
href,
page: source.title,
artwork: source.artwork,
}
: undefined
Expand All @@ -113,6 +124,16 @@ function WorkspacePlayer({
repeatLabel="Repeat demo"
repeating={repeat}
onRepeat={setRepeatPreference}
seek={
source && (
<ReleaseSeek
key={source.key}
position={position}
duration={source.duration}
onSeek={(next) => playback.seek(source.versionId, next)}
/>
)
}
>
{loading && <span role="status">Loading audio…</span>}
{error && (
Expand Down
90 changes: 86 additions & 4 deletions app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -558,16 +558,39 @@ body:has(.release-mini) {
border-top: 1px solid var(--color-border-control);
box-shadow: 0 -8px 30px #0005;
}
.release-mini-artwork {
.release-mini-transport {
position: relative;
flex: 0 0 52px;
height: 52px;
}
.release-mini-artwork img {
.release-mini-transport img {
display: block;
border-radius: 6px;
object-fit: cover;
}
.release-mini-transport:has(img) .play-toggle {
position: absolute;
inset: 0;
padding: 0;
border: 0;
border-radius: 6px;
background: transparent;
}
.release-mini-transport:has(img) .play-toggle svg {
box-sizing: content-box;
padding: 6px;
border: 1px solid var(--color-accent);
border-radius: 50%;
background: #090b0ae6;
box-shadow: 0 1px 6px #0008;
}
.release-mini-transport:has(img) .play-toggle:hover svg {
background: var(--color-surface);
border-color: var(--color-accent-strong);
}
.release-mini-description {
flex: 1;
flex: 0 1 auto;
max-width: 30%;
min-width: 0;
}
.release-mini-description a,
Expand All @@ -593,6 +616,28 @@ body:has(.release-mini) {
flex-basis: 100%;
margin: 0;
}
.release-mini .release-seek {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
margin: 0;
white-space: nowrap;
}
.release-mini .release-seek input {
flex: 1;
min-width: 0;
}
@media (max-width: 600px) {
.release-mini-description {
flex: 1;
max-width: none;
}
.release-mini .release-seek {
order: 1;
flex-basis: 100%;
}
}
.release-public {
max-width: 1120px;
margin: 4vh auto;
Expand Down Expand Up @@ -661,11 +706,48 @@ body:has(.release-mini) {
font-size: var(--text-sm);
}
.release-seek input[type="range"] {
/* Text-field padding offsets the native thumb from the progress track. */
appearance: none;
accent-color: var(--color-accent);
padding: 0;
border: 0;
background: transparent;
min-height: 44px;
cursor: pointer;
}
.release-seek input::-webkit-slider-runnable-track {
height: 6px;
border-radius: 3px;
background: linear-gradient(
to right,
var(--color-accent) var(--seek-progress),
var(--color-border-control) var(--seek-progress)
);
}
.release-seek input::-webkit-slider-thumb {
appearance: none;
width: 16px;
height: 16px;
margin-top: -5px;
border: 0;
border-radius: 50%;
background: var(--color-accent);
}
.release-seek input::-moz-range-track {
height: 6px;
border-radius: 3px;
background: var(--color-border-control);
}
.release-seek input::-moz-range-progress {
height: 6px;
border-radius: 3px;
background: var(--color-accent);
}
.release-seek input::-moz-range-thumb {
width: 16px;
height: 16px;
border: 0;
border-radius: 50%;
background: var(--color-accent);
}
.service-links {
display: grid;
Expand Down
4 changes: 2 additions & 2 deletions docs/wavecase-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ The listening session also shares a 96 MB (96,000,000 byte) in-memory LRU of alr

Ready seeks and playing demo version changes crossfade for at most 5 ms. A seek outside the prepared window briefly stops outgoing audio while fetching the target. During version preparation, keep the old version audible at its advancing position; failed preparation leaves it available for retry. Paused changes stay paused, and feedback timestamps override position preservation. Keep the current and most recently played demo version; the latter follows the current position with a shorter prepared window, including on mobile networks. Active playback has priority, and speculative transfers stop when its buffer runs low or playback pauses. The first switch to another version can require a short fetch; returning to a prepared version reuses its samples. Leaving the private workspace or learned revocation discards these caches. Audio ownership remains independent of waveform rendering.

The private workspace retains one active demo player across library, demo details, activity and other management pages. Opening another demo does not interrupt or replace the active track; pressing Play on it starts that track. Returning to the active demo reuses its version, position and prepared audio unless a version is explicitly requested. A bottom player shows the audible title and version, links back to that version, and offers play/pause and repeat. Space controls the active workspace player; editable fields and dialogs retain their keyboard behavior. Leaving the workspace, logout or account change stops playback. Listener share pages keep their own page-scoped player.
The private workspace retains one active demo player across library, demo details, activity and other management pages. Opening another demo does not interrupt or replace the active track; pressing Play on it starts that track. Returning to the active demo reuses its version, position and prepared audio unless a version is explicitly requested. A bottom player shows the audible title and version, links back to that version, and offers play/pause, repeat, elapsed/total time and a draggable position slider. Demo and release mini players share the release-page slider behavior, with mint progress and handles matching the site palette. Play/pause sits over available artwork as an always-visible mint icon on a dark circular backing, with a full-cover hit area and a visible keyboard focus outline. Without artwork, show the ordinary play/pause button in its place. The title remains the navigation link. Space controls the active workspace player, including with its position slider focused; editable fields and dialogs retain their keyboard behavior. Leaving the workspace, logout or account change stops playback. Listener share pages keep their own page-scoped player.

Library rows have a separate play/pause button at the far left. Play chooses the newest ready version with available playback audio, matching an ordinary first visit to the demo; newer processing/failed/missing versions do not replace it. Tracks without playable audio have a disabled control. Playback buttons do not navigate, while the rest of the row opens the demo. No automatic demo queue is created, and owner playback creates no listener analytics.

Expand Down Expand Up @@ -191,7 +191,7 @@ Release, artist, and songwriter routes share one React Router layout and one pla
- Track controls and the mini player share state. Pause/resume retains position/queue. Advance automatically; after the final track ends retain its metadata, then Play restarts the original queue from the first selected track. A playback error stops instead of silently skipping.
- Dragging the public release position slider previews the target without seeking or fetching intermediate positions. Release commits one seek; canceling discards the preview. Click/tap commits on release, while keyboard and assistive changes retain immediate seeking. Ongoing playback and its normal buffering continue during the drag.
- The mini player's Repeat track control loops the current track instead of advancing. Turning it off restores normal queue progression at the end of the track. Loops count as new plays; user seeks and pause/resume do not.
- After music is selected, the mini player appears across public music pages. Artwork/title link to the queued release; artist is plain text, using track artist then release artist fallback. Media Session uses that artist and release title as album; release artwork is a fitted/padded 512 × 512 JPEG derived from the current authorized cover.
- After music is selected, the mini player appears across public music pages. The title links to the queued release; artwork carries the shared play/pause control; artist is plain text, using track artist then release artist fallback. Media Session uses that artist and release title as album; release artwork is a fitted/padded 512 × 512 JPEG derived from the current authorized cover.
- With music loaded, Space toggles the shared player even with another button or the position slider focused. Holding it toggles once without scrolling. Editing, other form inputs, selects, dialogs, composition, modifiers, and Enter retain native behavior; an empty player preserves normal Space behavior.
- Leaving for management, accounts, library, or demos disposes playback and its media session. A full reload starts empty. Newly learned unavailability stops affected playback; server authorization always applies. Future public music views join this layout without moving management/demo routes into it.

Expand Down
Loading