Skip to main content

Script

A Script augments a Playback by breaking it into named segments, called markers.

import {Player, Script} from "liqvid";

const script = new Script([
["slide-1", "1:00"],
["slide-2", "1:00"]
]);

<Player script={script}>{/* ... */}</Player>

Properties

markerIndex

Index of the active marker.

markerIndex: number;

markerName

Name of the active marker.

markerName: string;

markers

The array of markers, in the form [name, startTime, endTime].

markers: [string, number, number][];

playback

The underlying Playback instance.

playback: Playback;

Methods

constructor()

constructor(markers: Array<[string, string | number] | [string, string | number, string | number]>): Script;

back()

Seek playback to the previous marker.

back(): void;

forward()

Advance playback to the next marker.

forward(): void;

markerByName()

Get a marker by its name.

markerByName(name: string): [string, number, number];

markerNumberOf()

Returns the first index of a marker named name. Throws an error if no marker named name exists.

markerNumberOf(name: string): number;

parseEnd()

If end is a string, returns the ending time of the marker with that name. Otherwise, returns end.

parseEnd(end: number | string): number;

parseStart()

If start is a string, returns the starting time of the marker with that name. Otherwise, returns start.

parseStart(start: number | string): number;

Events

This class extends EventEmitter. It emits the following events:

markerupdate

Fired when the active marker changes. Callback receives the index of the previously active marker.