UNPKG

2.03 kBTypeScriptView Raw
1import { Seconds } from "../type/Units.js";
2import { Timeline, TimelineEvent } from "./Timeline.js";
3export type BasicPlaybackState = "started" | "stopped";
4export type PlaybackState = BasicPlaybackState | "paused";
5export interface StateTimelineEvent extends TimelineEvent {
6 state: PlaybackState;
7}
8/**
9 * A Timeline State. Provides the methods: `setStateAtTime("state", time)` and `getValueAtTime(time)`
10 * @param initial The initial state of the StateTimeline. Defaults to `undefined`
11 * @internal
12 */
13export declare class StateTimeline<AdditionalOptions extends Record<string, any> = Record<string, any>> extends Timeline<StateTimelineEvent & AdditionalOptions> {
14 readonly name: string;
15 /**
16 * The initial state
17 */
18 private _initial;
19 constructor(initial?: PlaybackState);
20 /**
21 * Returns the scheduled state scheduled before or at
22 * the given time.
23 * @param time The time to query.
24 * @return The name of the state input in setStateAtTime.
25 */
26 getValueAtTime(time: Seconds): PlaybackState;
27 /**
28 * Add a state to the timeline.
29 * @param state The name of the state to set.
30 * @param time The time to query.
31 * @param options Any additional options that are needed in the timeline.
32 */
33 setStateAtTime(state: PlaybackState, time: Seconds, options?: AdditionalOptions): this;
34 /**
35 * Return the event before the time with the given state
36 * @param state The state to look for
37 * @param time When to check before
38 * @return The event with the given state before the time
39 */
40 getLastState(state: PlaybackState, time: number): (StateTimelineEvent & AdditionalOptions) | undefined;
41 /**
42 * Return the event after the time with the given state
43 * @param state The state to look for
44 * @param time When to check from
45 * @return The event with the given state after the time
46 */
47 getNextState(state: PlaybackState, time: number): (StateTimelineEvent & AdditionalOptions) | undefined;
48}