Skip to content
Type

InputTrackQuery

Defines a query for input tracks. Can be used to query tracks tersely and expressively, which is especially useful for media inputs with many tracks, such as HLS manifests.

ts
type InputTrackQuery<T extends InputTrack> = {
	filter?: (track: T) => MaybePromise<boolean>;
	sortBy?: (track: T) => MaybePromise<number | number[]>;
};

See MaybePromise and InputTrack.

Used by

Properties

filter

ts
filter?: ((track: T) => MaybePromise<boolean>);

A filter predicate function called for every track. Returning or resolving to false excludes the track from the result.

See MaybePromise.

sortBy

ts
sortBy?: ((track: T) => MaybePromise<number | number[]>);

A function called for every track, used to define a track ordering. Tracks are ordered in ascending order using the value returned by this function. When the function returns an array of numbers arr, tracks will be sorted by arr[0] unless they have the same value, in which case they will be sorted by arr[1], and so on. This allows you to construct a list of ordering criteria, sorted by importance.

To help construct complex ordering criteria, the asc, desc, and prefer helper functions can be used.

See MaybePromise.

Released under the Mozilla Public License 2.0.