Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

760 B
Raw Blame
import { useCallback } from "react";
import { usePlayerStore } from "../player";
import { useStableHandlers } from "./useStableHandlers";

type AddAtPlacement = (path: string, placement: { start: number; track: number }) => unknown;

export function useTimelineAddAtPlayhead(
  addAsset: AddAtPlacement,
  addComposition: AddAtPlacement,
  projectId: string | null,
) {
  const placement = () => ({ start: usePlayerStore.getState().currentTime, track: 0 });
  return useStableHandlers(
    {
      addAssetAtPlayhead: useCallback((path: string) => addAsset(path, placement()), [addAsset]),
      addCompositionAtPlayhead: useCallback(
        (path: string) => addComposition(path, placement()),
        [addComposition],
      ),
    },
    projectId,
  );
}