Skip to content

TimelineView ​

A film's own timeline as an editor shows it: lanes, clips with their names, waveforms, a moving playhead.

tsx
import { Composition, TimelineView, Track } from "@uberscene/kit";

// TimelineView: a film's timeline as an editor shows it. In a real post the lanes come from the film itself, with
// timelineLanes(state) of @uberscene/sdk; here, a short film's lanes are written out.
const LANES = [
  {
    id: "shots",
    role: "general",
    kind: "picture" as const,
    clips: [
      { id: "fire", kind: "clip", from: 0, to: 1.125, label: "fire", title: "fire.webm" },
      { id: "falls", kind: "clip", from: 1.125, to: 2.25, label: "falls", title: "falls.webm" },
      { id: "storm", kind: "clip", from: 2.25, to: 3, label: "storm", title: "storm.webm" },
    ],
  },
  {
    id: "sfx",
    role: "effects",
    kind: "sound" as const,
    clips: [
      {
        id: "whoosh",
        kind: "audio",
        from: 0.9,
        to: 1.425,
        label: "whoosh",
        level: [0.1, 0.3, 0.7, 0.9, 0.6, 0.3, 0.1],
      },
      {
        id: "boom",
        kind: "audio",
        from: 2.25,
        to: 3,
        label: "boom",
        level: [1, 0.8, 0.6, 0.45, 0.35, 0.25, 0.2, 0.15, 0.1, 0.05],
      },
    ],
  },
  {
    id: "beds",
    role: "ambience",
    kind: "sound" as const,
    clips: [
      {
        id: "crackle",
        kind: "audio",
        from: 0,
        to: 1.2,
        label: "crackle",
        title: "Wood fire crackling",
        fade: { in: 0, out: 0.4 },
        level: [0.4, 0.6, 0.3, 0.7, 0.5, 0.4, 0.6, 0.3],
      },
      {
        id: "water",
        kind: "audio",
        from: 1.05,
        to: 2.325,
        label: "water",
        title: "At the Top of a Large Waterfall",
        fade: { in: 0.4, out: 0.3 },
        level: [0.5, 0.6, 0.55, 0.62, 0.58, 0.6, 0.57, 0.5],
      },
    ],
  },
];

export default function Video() {
  return (
    <Composition fps={30} width={1920} height={1080} background={{ type: "color", color: "#0b0d12" }}>
      <Track id="over" layout="free">
        <TimelineView
          markers={[
            { time: 1.125, label: "falls" },
            { time: 2.25, label: "storm" },
          ]}
          id="timeline"
          start={0}
          duration={3}
          length={3}
          lanes={LANES}
          box={{ x: 160, y: 240 }}
          width={1600}
          height={600}
        />
      </Track>
    </Composition>
  );
}

Props ​

Besides the timing props (start, anchor, at, offset, duration):

paramtypedefaultdescription
idstringThe component's id; its layer's id starts with it.
lanes{ id, track, role, kind, clips }[]The film's lanes, as timelineLanes() of @uberscene/sdk returns them for its resolved timeline.
lengthnumber (> 0)The film's length in seconds.
markers{ time, label, color }[][]Marks above the lanes, as an editor's ruler shows them: the film's markers, or moments chosen to point at.
box{"x":60,"y":1060}The timeline's top left, in pixels from the frame's top left.
widthnumber (> 0)960The timeline's width in pixels: the film's length (or the window) across it.
heightnumber (> 0)720The timeline's height in pixels: the strip of markers on top, then the lanes.
fromnumber (0..∞)0The film's second at which the layer starts: the playhead is there, then moves with the layer's clock.
windownumber (> 0)Seconds across the view. Left out: the whole film, the playhead sweeping once. With it, the view scrolls.
labelsbooleantrueWrite each clip's name on it: its element id, and what it plays.
rulerbooleantrueNumber the seconds in the strip on top.
groundbooleanfalseDraw it as a ground, as a background is: the layout check does not hold it to the safe zone. For a post whose timeline runs under the app's own buttons and caption, as an editor's screen in a phone video does.
colors{"ground":"#1b1e25","lane":"#22262e","picture":"#1f7a7f","sound":"#2d8a52","wave":"#a9f2c0","waveLit":"#e9fff0","text":"#e8f5ec","playhead":"#ff3b30","active":"#ff8a3d","marker":"#b06bd0"}The colours of the ground, lanes, picture and sound clips, waveforms, names, playhead, the clip in play, markers.

All components

MIT licensed.