Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Keep Video card playback controls centered

Bittidb558f00c355
diff --git a/src/components/workspace/VideoLibraryView.test.tsx b/src/components/workspace/VideoLibraryView.test.tsx
index eeaffe1..2a4251b 100644
--- a/src/components/workspace/VideoLibraryView.test.tsx
+++ b/src/components/workspace/VideoLibraryView.test.tsx
@@ -153,6 +153,15 @@ it("uses the first playback frame as the poster and keeps playback buttons separ
await screen.findByRole('img', {name: 'First frame of Film'});
expect(shotPoster).toHaveBeenCalledWith('D:/Project','media/film.mp4',4);
expect(screen.queryByRole('button',{name:'Open scenes'})).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', {name: 'Play Film'}));
+ const inline = view.container.querySelector<HTMLElement>('.video-card__player')!;
+ expect(within(inline).getByRole('button', {name: 'Pause Film'}).parentElement).toHaveClass('video-card__playback-controls');
+ expect(within(inline).getByRole('button', {name: 'Pop out Film'})).toBeInTheDocument();
+ expect(screen.queryByRole('button', {name: 'Close video preview'})).not.toBeInTheDocument();
+ expect(view.container.querySelector('.video-card__controls')).toBeNull();
+ fireEvent.click(within(inline).getByRole('button', {name: 'Pause Film'}));
+ fireEvent.click(within(inline).getByRole('button', {name: 'Replay Film'}));
+ expect(within(inline).getByRole('button', {name: 'Pause Film'})).toBeInTheDocument();
fireEvent.click(screen.getByRole('button',{name:'Pop out Film'})); expect(screen.getByRole('dialog')).toBeInTheDocument(); expect(screen.queryByLabelText('Scenes editor')).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button',{name:'Close video preview'}));
fireEvent.click(screen.getByRole('button',{name:'Open Film'}).closest('[role="listitem"]')!); expect(screen.getByLabelText('Scenes editor')).toBeInTheDocument();
diff --git a/src/components/workspace/VideoLibraryView.tsx b/src/components/workspace/VideoLibraryView.tsx
index 3cc0e64..f76f580 100644
--- a/src/components/workspace/VideoLibraryView.tsx
+++ b/src/components/workspace/VideoLibraryView.tsx
@@ -127,8 +127,8 @@ export function VideoLibraryView(props: ComponentProps<typeof GeneratorView> & {
<span className="music-song__art"><VideoPoster folderPath={folderPath} relativePath={first?.asset.relativePath} seconds={first?.start ?? 0} revision={props.generationCompletionTimes?.[first?.sceneId ?? ""] ?? first?.asset.createdAt} title={video.title} /></span><span className="music-song__info"><strong>{video.title}</strong><span>{scenes.length} scenes · {scenes.reduce((seconds, scene) => seconds + sceneDurationSeconds(scene), 0).toFixed(1)} s</span><span>{busy ? "Generating" : playable ? `${playable} / ${scenes.length} scenes ready` : "Draft"}</span></span>
</button>
{busy && <ProgressRing className="video-card__progress" size={20} value={progress > 0 ? progress : undefined} aria-label={`${video.title} generation progress`} />}
- {playable > 0 && <div className="video-card__controls"><button type="button" aria-label={`Play ${video.title}`} onClick={() => setPlayback({ id: video.id, popout: false })}><Play16 /></button><button type="button" aria-label={`Pop out ${video.title}`} onClick={() => setPlayback({ id: video.id, popout: true })}><OpenExternal16 /></button></div>}
- {playing?.id === video.id && !playback?.popout && <VideoPlayback key={video.id} video={video} config={config} folderPath={folderPath} popout={false} onClose={() => setPlayback(undefined)} />}
+ {playable > 0 && !(playing?.id === video.id && !playback?.popout) && <div className="video-card__controls"><button type="button" aria-label={`Play ${video.title}`} onClick={() => setPlayback({ id: video.id, popout: false })}><Play16 /></button><button type="button" aria-label={`Pop out ${video.title}`} onClick={() => setPlayback({ id: video.id, popout: true })}><OpenExternal16 /></button></div>}
+ {playing?.id === video.id && !playback?.popout && <VideoPlayback key={video.id} video={video} config={config} folderPath={folderPath} popout={false} onClose={() => setPlayback(undefined)} onPopout={() => setPlayback({ id: video.id, popout: true })} />}
</div>;
})}
</div>
diff --git a/src/components/workspace/VideoPlayback.tsx b/src/components/workspace/VideoPlayback.tsx
index f6bfa0e..d7f2a00 100644
--- a/src/components/workspace/VideoPlayback.tsx
+++ b/src/components/workspace/VideoPlayback.tsx
@@ -3,12 +3,12 @@ import type { ProjectConfig, ProjectVideo } from "../../lib/project";
import { outputDimensions } from "../../lib/export";
import { videoPlaybackConfig, videoPlaylist } from "../../lib/videoPlayback";
import { ProgramMonitor } from "./ProgramMonitor";
-import { Dismiss16, Pause20, Play20Filled } from "../ui/icons";
+import { Dismiss16, OpenExternal16, Pause20, Play20Filled } from "../ui/icons";
export { videoPlaylist } from "../../lib/videoPlayback";
/** Timeline's continuous clock, prepared players and persistent compositor. */
-export function VideoPlayback({ video: item, config, folderPath, popout, onClose }: {
- video: ProjectVideo; config: ProjectConfig; folderPath: string; popout: boolean; onClose: () => void;
+export function VideoPlayback({ video: item, config, folderPath, popout, onClose, onPopout }: {
+ video: ProjectVideo; config: ProjectConfig; folderPath: string; popout: boolean; onClose: () => void; onPopout?: () => void;
}) {
// Play the takes opened by the user. Progress updates and completed renders
// must not recreate media objects, unload decoders or replace a playing file.
@@ -35,14 +35,20 @@ export function VideoPlayback({ video: item, config, folderPath, popout, onClose
if (popout && focused?.isConnected) focused.focus();
};
}, [popout]);
+ const playButton = <button type="button" className={popout ? "shot-popout__play" : undefined} aria-label={(playing ? "Pause " : "Replay ") + item.title} disabled={!duration} onClick={() => {
+ if (playing) setPlaying(false);
+ else { if (playhead >= duration) setPlayhead(0); setPlaying(true); }
+ }}>{playing ? <Pause20 /> : <Play20Filled />}</button>;
const player = <div className={popout ? "shot-popout__frame" : "video-card__player"} ref={frame} tabIndex={-1}
role={popout ? "dialog" : "group"} aria-label={item.title + " preview"} style={{ "--shot-aspect": dimensions.width / dimensions.height } as CSSProperties}>
<ProgramMonitor config={preview} folderPath={folderPath} playheadMs={Math.min(playhead, Math.max(0, duration - 1))} playing={playing} waitForInitialFrame onSeek={setPlayhead} onPlayingChange={setPlaying} />
- <button type="button" className="shot-popout__close" aria-label="Close video preview" onClick={onClose}><Dismiss16 /></button>
- <button type="button" className="shot-popout__play" aria-label={(playing ? "Pause " : "Replay ") + item.title} disabled={!duration} onClick={() => {
- if (playing) setPlaying(false);
- else { if (playhead >= duration) setPlayhead(0); setPlaying(true); }
- }}>{playing ? <Pause20 /> : <Play20Filled />}</button>
+ {popout ? <>
+ <button type="button" className="shot-popout__close" aria-label="Close video preview" onClick={onClose}><Dismiss16 /></button>
+ {playButton}
+ </> : <div className="video-card__playback-controls">
+ {playButton}
+ {onPopout && <button type="button" aria-label={`Pop out ${item.title}`} onClick={onPopout}><OpenExternal16 /></button>}
+ </div>}
<span className="video-card__position">{playhead >= duration ? playlist.length : index + 1} / {playlist.length} · {current?.title}</span>
</div>;
return popout ? <div className="shot-popout">{player}</div> : player;
diff --git a/src/styles/video-library.css b/src/styles/video-library.css
index 83f879c..72f73c0 100644
--- a/src/styles/video-library.css
+++ b/src/styles/video-library.css
@@ -19,16 +19,17 @@
.video-folder .music-song__art { flex: none; aspect-ratio: 16 / 9; background: color-mix(in srgb, var(--accent) 8%, var(--surface-pane)); }
.video-folder .music-song__art svg { width: 64px; height: 64px; }
.video-card__controls { position: absolute; top: calc((100cqw - 12px) / var(--video-card-aspect, 1.7777778) / 2 + 6px); left: 50%; transform: translate(-50%, -50%); display: flex; gap: var(--space-2); }
-.video-card__controls button { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #ffffff80; border-radius: 50%; background: #15191fe6; color: #fff; box-shadow: 0 1px 6px #0008; }
-.video-card__controls button:hover { background: #363d48; }
+.video-card__playback-controls { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; gap: var(--space-2); }
+.video-card__controls button, .video-card__playback-controls button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid #ffffff80; border-radius: 50%; background: #15191fe6; color: #fff; box-shadow: 0 1px 6px #0008; }
+.video-card__controls button:hover, .video-card__playback-controls button:hover { background: #363d48; }
+.video-card__controls svg, .video-card__playback-controls svg { width: 20px; height: 20px; }
.video-card__player { position: absolute; top: 6px; left: 6px; right: 6px; aspect-ratio: var(--video-card-aspect, 16 / 9); background: #000; z-index: 2; }
.video-card__player video { width: 100%; height: 100%; object-fit: contain; }
.video-card__position { position: absolute; left: var(--space-2); top: var(--space-2); color: #fff; background: #000b; padding: 2px 5px; font-size: var(--text-xs); pointer-events: none; max-width: 70%; }
-.music-songs--list .video-card > .music-song__select { padding-right: 100px; min-height: 82px; }
+.music-songs--list .video-card > .music-song__select { min-height: 82px; }
.music-songs--list .video-card .music-song__art { width: 120px; height: 67.5px; }
.music-songs--list .video-folder > .music-song__select { min-height: 82px; padding-right: 6px; }
.music-songs--list .video-folder .music-song__art { width: 120px; height: 67.5px; }
.music-songs--list .video-folder .music-song__art svg { width: 32px; height: 32px; }
-.music-songs--list .video-card__controls { top: 50%; left: auto; right: 12px; transform: translateY(-50%); }
-.music-songs--list .video-card--busy .video-card__controls { top: calc(50% - 8px); }
-.music-songs--list .video-card__player { inset: 0; aspect-ratio: auto; }
+.music-songs--list .video-card__controls { top: 50%; left: 66px; transform: translate(-50%, -50%); }
+.music-songs--list .video-card__player { top: 50%; right: auto; width: 120px; height: 67.5px; aspect-ratio: auto; transform: translateY(-50%); }