feat: autoplay inbound clips

This commit is contained in:
talksik
2026-03-21 17:59:41 -07:00
parent 18f587864f
commit 4a4d213eb6
6 changed files with 122 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
import { create } from "zustand";
import type { Particle } from "@/api/types";
type MediaParticle = Extract<Particle, { type: "media" }>;
interface AutoplayState {
/** The media particle currently being autoplayed, null when idle */
activeParticle: MediaParticle | null;
/** The stream this particle belongs to (for click-to-navigate) */
streamId: string | null;
/** Play a media particle, preempting any currently playing */
play: (particle: MediaParticle, streamId: string) => void;
/** Stop autoplay and clear state */
stop: () => void;
}
export const useAutoplayStore = create<AutoplayState>((set) => ({
activeParticle: null,
streamId: null,
play: (particle, streamId) => set({ activeParticle: particle, streamId }),
stop: () => set({ activeParticle: null, streamId: null }),
}));