@vestra-player/sdk - v1.11.3
    Preparing search index...

    Interface Timeline

    plugin.timeline: marks on the seek bar. Every plugin publishes one layer; the player merges them. A new source clears every layer.

    Marks on the player's seek bar: chapters, bookmarks, loop points. Each plugin publishes one layer with Timeline.layer; the player merges the layers by time and shows them. A new source clears every layer, so a plugin publishes again for each file. marks is the merged list, which any plugin can read. To run code when they change, listen with plugin.player.on("timeline.changed", …): marks and ranges already hold the event's lists when the listener runs, and follow the player while it listens.

    The plugin reads how many chapter marks the seek bar shows, whoever published them. marks is the merged list of every layer, sorted by time, with each mark's plugin.

    const chapters = plugin.timeline.marks.filter((mark) => mark.kind === "chapter");
    await plugin.osd.show("{} chapters", [chapters.length]);

    1.0.0

    interface Timeline {
        marks: readonly TimelineMark[];
        ranges: readonly TimelineRange[];
        layer(): TimelineLayer;
    }
    Index
    • This plugin's layer (timeline.marks); a second call throws.

      Returns TimelineLayer

      The plugin gets its one layer and puts two chapter marks on the seek bar. Calling layer() again while the first layer is not disposed throws; disposing the layer removes the marks.

      const layer = plugin.timeline.layer();
      layer.set([
      { time: 0, kind: "chapter", title: "Intro" },
      { time: 95, kind: "chapter", title: "Part 1" }, // seconds
      ]);

      1.0.0

    marks: readonly TimelineMark[]

    Every layer merged, by time. Empty on a new source.

    ranges: readonly TimelineRange[]

    Every layer's ranges merged, by start. Empty on a new source. Kept current like marks (while a timeline.changed listener exists): read it in a View.bind function and the view follows it.

    A bottom bar draws a band for every range on the seek bar, whoever published it, as fractions of the duration.

    bar.bind(() => {
    // Reading `ranges` here runs the binding again when they change.
    const duration = plugin.player.state.duration ?? 0;
    return {
    ranges: duration
    ? plugin.timeline.ranges.map((range) => ({
    from: range.start / duration,
    to: range.end / duration,
    selection: range.style === "selection",
    }))
    : [],
    };
    });

    1.6.9