feat: autoplay inbound clips
This commit is contained in:
@@ -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 }),
|
||||
}));
|
||||
Reference in New Issue
Block a user