Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Keep music playing across pages

Bittib879a7688ecd
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index c4ef269..8f4c268 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -4,7 +4,7 @@ Changes since 0.3.2.
## What's new
-- **Music.** YuE2 and MiniMax Music3 generation with folders, drag-and-drop organization, grid/list views, continuous playback, references and timeline audio. YuE2 selects BF16 above 8 GiB VRAM, otherwise INT8.
+- **Music.** YuE2 and MiniMax Music3 generation with folders, drag-and-drop organization, grid/list views, background playback, references and timeline audio. Playback appears in the Music tab and pauses when Timeline, Video or Export playback starts. YuE2 selects BF16 above 8 GiB VRAM, otherwise INT8.
- **Motions.** Create JavaScript animations with the agent, edit elements and parameters, and export them on the timeline or as reference videos.
- **Scene history.** Keep up to four takes and an editable Draft, restore take settings, choose the primary timeline video, and duplicate scenes.
- **Agent frame inspection.** Agents can view timeline frames, scenes, takes, references, generated images and Motions at a requested time.
diff --git a/src/components/ProjectWorkspace.music.test.tsx b/src/components/ProjectWorkspace.music.test.tsx
new file mode 100644
index 0000000..4358afe
--- /dev/null
+++ b/src/components/ProjectWorkspace.music.test.tsx
@@ -0,0 +1,107 @@
+// @vitest-environment jsdom
+import "@testing-library/jest-dom/vitest";
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { createPortal } from "react-dom";
+import { ProjectWorkspace } from "./ProjectWorkspace";
+import { createProjectConfig } from "../lib/project";
+import { newSong } from "../lib/music";
+import { readMediaFileUrl } from "../lib/persistence";
+import { notifyPreviewPlayback } from "../lib/mediaPlayback";
+
+vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
+vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));
+vi.mock("../lib/persistence", async (original) => ({ ...await original<typeof import("../lib/persistence")>(),
+ readMediaFileUrl: vi.fn(async (_, asset) => `blob:${asset.relativePath}`),
+}));
+// Exercise workspace media-event routing, including React portals used by shot popouts.
+vi.mock("./workspace/GeneratorView", () => ({ GeneratorView: () => <><video aria-label="Shot" />{createPortal(<video aria-label="Popout" />, document.body)}</> }));
+vi.mock("./workspace/TimelineView", () => ({ TimelineView: () => <audio aria-label="Timeline preview" /> }));
+vi.mock("./workspace/ExportView", () => ({ ExportView: () => <video aria-label="Export preview" /> }));
+vi.mock("./workspace/ReferencesView", () => ({ ReferencesView: () => <div>References page</div> }));
+
+beforeEach(() => {
+ localStorage.clear();
+ vi.spyOn(HTMLMediaElement.prototype, "pause").mockImplementation(function (this: HTMLMediaElement) { this.dispatchEvent(new Event("pause")); });
+ vi.spyOn(HTMLMediaElement.prototype, "play").mockImplementation(function (this: HTMLMediaElement) { this.dispatchEvent(new Event("play")); return Promise.resolve(); });
+ vi.stubGlobal("URL", Object.assign(URL, { revokeObjectURL: vi.fn() }));
+ vi.mocked(readMediaFileUrl).mockImplementation(async (_, asset) => `blob:${asset.relativePath}`);
+});
+afterEach(() => { cleanup(); vi.restoreAllMocks(); vi.unstubAllGlobals(); vi.clearAllMocks(); });
+
+function workspace() {
+ const songs = ["First", "Second"].map((title) => ({ ...newSong(), title, assetId: title, status: "completed" as const }));
+ const config = { ...createProjectConfig({ name: "Music test", prompt: "", aspectRatio: "16:9", resolution: "416p", targetDurationSeconds: 30 }),
+ musicSongs: songs, assets: songs.map((song) => ({ id: song.assetId, kind: "audio" as const, name: song.title,
+ relativePath: `media/${song.title}.wav`, durationMs: 30000, mimeType: "audio/wav", createdAt: song.createdAt })) };
+ return render(<ProjectWorkspace project={{ folderPath: "C:/Music", config }} initialView="music" onBack={() => {}} onSave={async () => {}} />);
+}
+
+async function start() {
+ fireEvent.click(screen.getByRole("button", { name: "Play First" }));
+ const audio = document.querySelector<HTMLAudioElement>(".music-view audio")!;
+ await waitFor(() => expect(audio).toHaveAttribute("src", "blob:media/First.wav"));
+ fireEvent.canPlay(audio);
+ expect(screen.getByRole("tab", { name: "Music Playing" })).toBeInTheDocument();
+ return audio;
+}
+
+it("keeps music and its playlist alive across tabs, preserves position and stops on project exit", async () => {
+ const view = workspace();
+ const audio = await start();
+ audio.currentTime = 12;
+ fireEvent.timeUpdate(audio);
+ vi.mocked(audio.pause).mockClear();
+ fireEvent.click(screen.getByRole("tab", { name: "References" }));
+ expect(audio).toBeInTheDocument();
+ expect(audio).not.toBeVisible();
+ expect(audio.pause).not.toHaveBeenCalled();
+ expect(screen.getByRole("tab", { name: "Music Playing" })).toHaveAttribute("aria-selected", "false");
+ expect(screen.getByText("2 songs")).not.toBeVisible();
+ fireEvent.click(screen.getByRole("tab", { name: "Music Playing" }));
+ expect(document.querySelector(".music-view audio")).toBe(audio);
+ expect(audio.currentTime).toBe(12);
+ expect(screen.getByRole("button", { name: "Pause music" })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("tab", { name: "Video" }));
+ fireEvent.ended(audio);
+ await waitFor(() => expect(audio).toHaveAttribute("src", "blob:media/Second.wav"));
+ fireEvent.canPlay(audio);
+ expect(screen.getByRole("tab", { name: "Music Playing" })).toBeInTheDocument();
+ vi.mocked(audio.pause).mockClear();
+ view.unmount();
+ expect(audio.pause).toHaveBeenCalled();
+});
+
+it.each([["Timeline", "Timeline preview"], ["Video", "Shot"], ["Video", "Popout"], ["Export", "Export preview"]])(
+ "pauses background music when %s playback starts (%s), then allows manual resume", async (tab, preview) => {
+ workspace();
+ const audio = await start();
+ audio.currentTime = 7;
+ fireEvent.click(screen.getByRole("tab", { name: tab }));
+ expect(screen.getByRole("tab", { name: "Music Playing" })).toBeInTheDocument();
+ fireEvent.play(screen.getByLabelText(preview));
+ expect(within(screen.getByRole("tab", { name: "Music" })).queryByRole("img", { name: "Playing" })).not.toBeInTheDocument();
+ expect(audio.currentTime).toBe(7);
+ fireEvent.click(screen.getByRole("tab", { name: "Music" }));
+ expect(screen.getByRole("button", { name: "Play music" })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: "Play music" }));
+ expect(screen.getByRole("tab", { name: "Music Playing" })).toBeInTheDocument();
+ },
+);
+
+it("cancels pending autoplay and late playback/ended events when another player takes over", async () => {
+ let loaded!: (url: string) => void;
+ vi.mocked(readMediaFileUrl).mockImplementationOnce(() => new Promise((resolve) => { loaded = resolve; }));
+ workspace();
+ fireEvent.click(screen.getByRole("button", { name: "Play First" }));
+ const audio = document.querySelector<HTMLAudioElement>(".music-view audio")!;
+ act(() => notifyPreviewPlayback());
+ await act(async () => loaded("blob:media/First.wav"));
+ fireEvent.canPlay(audio);
+ expect(audio.play).not.toHaveBeenCalled();
+ fireEvent.play(audio);
+ fireEvent.ended(audio);
+ expect(screen.getByRole("tab", { name: "Music" })).toBeInTheDocument();
+ expect(audio).toHaveAttribute("src", "blob:media/First.wav");
+ expect(readMediaFileUrl).toHaveBeenCalledTimes(1);
+});
diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsx
index cd73002..11366d9 100644
--- a/src/components/ProjectWorkspace.tsx
+++ b/src/components/ProjectWorkspace.tsx
@@ -1,6 +1,7 @@
import { Agent16, Agent16Filled, Back16, ChevronDown12, Download16, Download16Filled, Film16, Film16Filled, Image16, Image16Filled, Redo16, References16, References16Filled, Save16, Sparkle16, Sparkle16Filled, Undo16 } from "./ui/icons";
import { MusicView } from "./workspace/MusicView";
-import { Audio16 } from "./ui/icons";
+import { Audio16, Speaker14 } from "./ui/icons";
+import { notifyPreviewPlayback } from "../lib/mediaPlayback";
import { ImageEditor } from "./workspace/ImageEditor";
import { useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
import type { GenerationJob, ProjectConfig, ProjectRecord } from "../lib/project";
@@ -123,8 +124,11 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,
// Legacy project types choose only the initial view; every project has both editors.
const openingView = initialView === "agent" ? "timeline" : initialView ?? (config.generationType === "image" ? "editor" : "timeline");
const [view, setShownView] = useState<ShownView>(openingView);
+ const [musicVisited, setMusicVisited] = useState(openingView === "music");
+ const [musicPlaying, setMusicPlaying] = useState(false);
const [mediaMode, setMediaMode] = useState<"video" | "image">(() => openingView === "editor" || ((openingView === "references" || openingView === "export") && config.generationType === "image") ? "image" : "video");
const setView = (next: ShownView) => {
+ if (next === "music") setMusicVisited(true);
if (next === "editor") setMediaMode("image");
else if (next === "generator" || next === "timeline") setMediaMode("video");
setShownView(next);
@@ -277,7 +281,7 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,
controls: `${panelId}-view`,
label: id === "generator" && running > 0
? <span className="project-views__label" data-tooltip={`${running} generation${running === 1 ? "" : "s"} running or queued`} data-tooltip-shortcut={shortcutOf(views.indexOf(id))}><span className="project-views__name" data-label={VIEW_LABELS[id]}>{VIEW_LABELS[id]}</span><InfoBadge value={running} severity="informational" /></span>
- : <span className="project-views__label" data-tooltip={VIEW_LABELS[id]} data-tooltip-shortcut={shortcutOf(views.indexOf(id))}><span className="project-views__name" data-label={VIEW_LABELS[id]}>{VIEW_LABELS[id]}</span></span>,
+ : <span className="project-views__label" data-tooltip={id === "music" && musicPlaying ? "Music playing" : VIEW_LABELS[id]} data-tooltip-shortcut={shortcutOf(views.indexOf(id))}><span className="project-views__name" data-label={VIEW_LABELS[id]}>{VIEW_LABELS[id]}</span>{id === "music" && musicPlaying && <Speaker14 role="img" aria-label="Playing" className="project-views__playing" />}</span>,
icon: viewIcon(id, id === view),
}))}
/>
@@ -289,8 +293,12 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,
<ProjectStatusSlot.Provider value={statusSlot}>
<div className={`project-body${agentOpen ? " project-body--agent" : ""}`} style={agentPane.style}>
- <div id={`${panelId}-view`} role="tabpanel" aria-label={VIEW_LABELS[view]} className={`project-content project-content--${view}`}>
- {view === "music" && <MusicView openSong={musicNavigation} onSongOpened={() => setMusicNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(id, template) => queue.enqueueMusic(session, id, template)} onCancel={(id) => void queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "music")} />}
+ <div id={`${panelId}-view`} role="tabpanel" aria-label={VIEW_LABELS[view]} className={`project-content project-content--${view}`} onPlayCapture={(event) => {
+ if (["timeline", "generator", "export"].includes(view) && event.target instanceof Element && !event.target.closest(".music-view")) notifyPreviewPlayback();
+ }}>
+ {musicVisited && <div hidden={view !== "music"} style={{ height: "100%", display: view === "music" ? "block" : "none" }}>
+ <MusicView active={view === "music"} onPlayingChange={setMusicPlaying} openSong={musicNavigation} onSongOpened={() => setMusicNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(id, template) => queue.enqueueMusic(session, id, template)} onCancel={(id) => void queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "music")} />
+ </div>}
{view === "editor" && <ImageEditor openImage={imageNavigation} onImageOpened={() => setImageNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template, count) => queue.enqueueImage(session, template, count)} onGenerateCharacterSheet={(template, sourceId, options) => queue.enqueueCharacterSheet(session, template, sourceId, options)} onGenerateExtend={(template, sourceId, options) => queue.enqueueExtendImage(session, template, sourceId, options)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} onOpenReferences={() => setView("references")} />}
{view === "timeline" && <TimelineView config={config} openSceneId={selectedGenerationJobId} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} onChange={changeConfig} onMeasured={recordMeasurement} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} />}
{view === "generator" && <GeneratorView onGenerate={(submissions) => queue.enqueue(session, submissions)} onCancelGeneration={(ids) => queue.cancelScenes(session, ids)} cancellingJobIds={cancellingJobIds} config={config} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} runtime={runtime?.slopfab ?? null} onRuntimeChange={onGeneratorRuntimeChange} onChange={changeConfig} selectedJobId={selectedGenerationJobId} onSelectedJobChange={setSelectedGenerationJobId} onOpenTimeline={() => setView("timeline")} />}
diff --git a/src/components/workspace/MusicView.tsx b/src/components/workspace/MusicView.tsx
index 018ef85..17118fa 100644
--- a/src/components/workspace/MusicView.tsx
+++ b/src/components/workspace/MusicView.tsx
@@ -11,11 +11,13 @@ import { SliderNumberInput, GENERATION_STEPS_RANGE } from "./SliderNumberInput";
import type { ConfigUpdate } from "./TimelineView";
import { GeneratorSelector } from "./GeneratorSelector";
import { ProjectStatus } from "./ProjectStatus";
+import { PREVIEW_PLAYBACK_STARTED } from "../../lib/mediaPlayback";
const time = (seconds: number) => `${Math.floor(seconds / 60)}:${Math.floor(seconds % 60).toString().padStart(2, "0")}`;
const SONG_DRAG_TYPE = "application/x-slopus-music-song";
-export function MusicView({ config, folderPath, onChange, onGenerate, onCancel, workItems, openSong, onSongOpened }: {
+export function MusicView({ config, folderPath, onChange, onGenerate, onCancel, workItems, openSong, onSongOpened, active = true, onPlayingChange }: {
+ active?: boolean; onPlayingChange?: (playing: boolean) => void;
openSong?: { id: string }; onSongOpened?: () => void;
config: ProjectConfig; folderPath: string; onChange: (update: ConfigUpdate, key?: string) => void;
onGenerate: (songId: string, template: GeneratorTemplate) => string | void; onCancel: (id: string) => void;
@@ -49,6 +51,7 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onCancel,
const [view, setView] = useState<"grid" | "list">(() => localStorage.getItem("slopus.music.view") === "list" ? "list" : "grid");
const inspector = usePaneSize("music.inspector", 340, { min: 280, max: 560 });
const menu = useContextMenu();
+ useEffect(() => { if (!active) menu.close(); }, [active, menu.close]);
const [error, setError] = useState<string | null>(null);
const [notice, setNotice] = useState<string | null>(null);
const activeWork = selected && workItems.find((item) => item.sceneId === selected.id && isWorkActive(item));
@@ -130,6 +133,24 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onCancel,
const [length, setLength] = useState(0);
const [volume, setVolume] = useState(0.8);
const playWhenReady = useRef(false);
+ const interrupted = useRef(false);
+ useEffect(() => { onPlayingChange?.(playing); }, [playing, onPlayingChange]);
+ useEffect(() => {
+ const media = audio.current;
+ const pause = () => {
+ interrupted.current = true;
+ playWhenReady.current = false;
+ media?.pause();
+ setPlaying(false);
+ };
+ window.addEventListener(PREVIEW_PLAYBACK_STARTED, pause);
+ return () => {
+ window.removeEventListener(PREVIEW_PLAYBACK_STARTED, pause);
+ interrupted.current = true;
+ playWhenReady.current = false;
+ media?.pause();
+ };
+ }, []);
const [playbackError, setPlaybackError] = useState<string | null>(null);
const visiblePlayable = visibleSongs.flatMap((song) => {
const asset = config.assets.find((item) => item.id === song.assetId && item.kind === "audio" && item.relativePath);
@@ -154,9 +175,10 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onCancel,
}, [folderPath, playerAsset?.id, playerAsset?.relativePath]);
useEffect(() => { if (audio.current) audio.current.volume = volume; }, [volume, url]);
const play = async () => {
- try { await audio.current?.play(); } catch (reason) { setPlaybackError(`Could not play song: ${String(reason)}`); setPlaying(false); }
+ try { await audio.current?.play(); } catch (reason) { if (!interrupted.current) { setPlaybackError(`Could not play song: ${String(reason)}`); setPlaying(false); } }
};
const playAsset = (asset: ProjectAsset) => {
+ interrupted.current = false;
setPlaybackError(null);
if (asset.id === playerId && url) void play();
else { playWhenReady.current = true; setPlayerId(asset.id); }
@@ -302,17 +324,17 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onCancel,
</div>
<div className="music-player__volume"><Speaker14 /><Slider aria-label="Music volume" min={0} max={1} step={0.01} value={volume} onChange={setVolume} /></div>
{playbackError && <p className="music-player__error" role="alert">{playbackError}</p>}
- <audio ref={audio} src={url ?? undefined} preload="metadata" onPlay={() => setPlaying(true)} onPause={() => setPlaying(false)}
+ <audio ref={audio} src={url ?? undefined} preload="metadata" onPlay={() => { if (interrupted.current) audio.current?.pause(); else setPlaying(true); }} onPause={() => setPlaying(false)}
onLoadedMetadata={(event) => { const duration = event.currentTarget.duration; setLength(Number.isFinite(duration) ? duration : 0); }}
onCanPlay={() => { if (playWhenReady.current) { playWhenReady.current = false; void play(); } }}
- onTimeUpdate={(event) => setPosition(event.currentTarget.currentTime)} onEnded={() => { setPlaying(false); const index = playable.findIndex(({ asset }) => asset.id === playerId); if (index >= 0 && index + 1 < playable.length) playAsset(playable[index + 1].asset); }}
+ onTimeUpdate={(event) => setPosition(event.currentTarget.currentTime)} onEnded={() => { setPlaying(false); if (interrupted.current) return; const index = playable.findIndex(({ asset }) => asset.id === playerId); if (index >= 0 && index + 1 < playable.length) playAsset(playable[index + 1].asset); }}
onError={() => { if (url) { playWhenReady.current = false; setPlaying(false); setPlaybackError("This song could not be played."); } }} />
</div>
</div>
- <ProjectStatus label="Music status">
+ {active && <ProjectStatus label="Music status">
<span>{config.musicSongs?.length ?? 0} songs</span>
{generatorStatus.state !== "ready" && <span className="generator-status__runtime">{generatorStatus.detail}</span>}
- </ProjectStatus>
- {menu.element}
+ </ProjectStatus>}
+ {active && menu.element}
</div>;
}
diff --git a/src/components/workspace/ProgramMonitor.test.tsx b/src/components/workspace/ProgramMonitor.test.tsx
index 2c219e3..7d06411 100644
--- a/src/components/workspace/ProgramMonitor.test.tsx
+++ b/src/components/workspace/ProgramMonitor.test.tsx
@@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createDraftGenerationJob, createProjectConfig, parseProjectConfig, STORY_TRACK_ID, type ProjectConfig, type TimelineClip } from "../../lib/project";
import { ProgramMonitor } from "./ProgramMonitor";
import { PreviewSources } from "../../lib/exportPipeline";
+import { PREVIEW_PLAYBACK_STARTED } from "../../lib/mediaPlayback";
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
beforeEach(() => { vi.spyOn(HTMLMediaElement.prototype, "load").mockImplementation(() => undefined); });
@@ -53,6 +54,23 @@ const monitor = (config: ProjectConfig, playheadMs: number) => render(
);
describe("the program monitor", () => {
+ it("yields background music only when the Timeline/Export transport starts, including reverse", () => {
+ const started = vi.fn();
+ window.addEventListener(PREVIEW_PLAYBACK_STARTED, started);
+ const props = { config: project([clip()]), folderPath: "C:/Film", onSeek: vi.fn(), onPlayingChange: vi.fn() };
+ try {
+ const view = render(<ProgramMonitor {...props} playheadMs={2000} playing={false} />);
+ view.rerender(<ProgramMonitor {...props} playheadMs={2500} playing={false} />);
+ expect(started).not.toHaveBeenCalled();
+ view.rerender(<ProgramMonitor {...props} playheadMs={2500} playing />);
+ expect(started).toHaveBeenCalledTimes(1);
+ view.rerender(<ProgramMonitor {...props} playheadMs={3000} playing />);
+ expect(started).toHaveBeenCalledTimes(1);
+ view.rerender(<ProgramMonitor {...props} playheadMs={3000} playing={false} />);
+ view.rerender(<ProgramMonitor {...props} playheadMs={3000} playing rate={-1} />);
+ expect(started).toHaveBeenCalledTimes(2);
+ } finally { window.removeEventListener(PREVIEW_PLAYBACK_STARTED, started); }
+ });
it.each([1, 2])("keeps the Long Shot video running across both bridge boundaries at %sx speed", async (playbackRate) => {
const read = vi.spyOn(PreviewSources.prototype, "url").mockImplementation(async (asset) => `blob:${asset.id}`);
const playingElements = new WeakSet<HTMLMediaElement>();
diff --git a/src/components/workspace/ProgramMonitor.tsx b/src/components/workspace/ProgramMonitor.tsx
index 28ed139..f075640 100644
--- a/src/components/workspace/ProgramMonitor.tsx
+++ b/src/components/workspace/ProgramMonitor.tsx
@@ -14,6 +14,7 @@ import { preparedPreviewClips, previewPlayerKeys, previewSegmentIndex, previewSe
import { PreviewMedia } from "../../lib/previewPresentation";
import { PLAYBACK_SAMPLE_MS, previewEngine } from "../../lib/previewEngine";
import { continuationPlaybackTracks } from "../../lib/continuationMedia";
+import { notifyPreviewPlayback } from "../../lib/mediaPlayback";
/* The monitor owns a continuous timeline clock. Visible and upcoming clips
* prepare persistent media elements ahead of a cut. Adjacent ranges of a joined
@@ -241,6 +242,7 @@ export function ProgramMonitor({ config, folderPath, playheadMs, playing, rate =
published once a second, never through this component's state. */
useEffect(() => {
if (!playing) return;
+ notifyPreviewPlayback();
previewEngine.start();
let last = performance.now();
const timer = window.setInterval(() => {
diff --git a/src/lib/mediaPlayback.ts b/src/lib/mediaPlayback.ts
new file mode 100644
index 0000000..6a000c9
--- /dev/null
+++ b/src/lib/mediaPlayback.ts
@@ -0,0 +1,6 @@
+/** Timeline/Export transport and native previews yield background Music playback. */
+export const PREVIEW_PLAYBACK_STARTED = "slopus:preview-playback-started";
+
+export function notifyPreviewPlayback() {
+ window.dispatchEvent(new Event(PREVIEW_PLAYBACK_STARTED));
+}
diff --git a/src/styles/workspace.css b/src/styles/workspace.css
index 85d6f5f..e5c75e3 100644
--- a/src/styles/workspace.css
+++ b/src/styles/workspace.css
@@ -106,6 +106,13 @@
display: inline-grid;
}
+.project-views__playing {
+ color: var(--accent-bright);
+ width: 16px;
+ height: 16px;
+ flex-shrink: 0;
+}
+
.project-views__name::after {
content: attr(data-label);
height: 0;