This plugin's layer (timeline.marks); a second call throws.
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
]);
ReadonlymarksEvery layer merged, by time. Empty on a new source.
ReadonlyrangesEvery 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",
}))
: [],
};
});
plugin.timeline: marks on the seek bar. Every plugin publishes one layer; the player merges them. A new source clears every layer.Remarks
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.
marksis the merged list, which any plugin can read. To run code when they change, listen withplugin.player.on("timeline.changed", …):marksandrangesalready hold the event's lists when the listener runs, and follow the player while it listens.Example: Count the chapter marks other plugins published
The plugin reads how many chapter marks the seek bar shows, whoever published them.
marksis the merged list of every layer, sorted by time, with each mark'splugin.Since
1.0.0