Skip to content
Client
Server

Reference / @open-music-sdk/lib-preview-player / tPreviewAudio

Interface: tPreviewAudio ​

Defined in: lib/lib-preview-player/src/player.ts:22

The part of an audio element the player uses. An HTMLAudioElement fits, and so does a test's own. Each member is read or called as the element's is, and means what it means there.

Properties ​

currentTime ​

ts
currentTime: number;

Defined in: lib/lib-preview-player/src/player.ts:26

How far into the clip the element is, in seconds. Set by seek.


duration ​

ts
readonly duration: number;

Defined in: lib/lib-preview-player/src/player.ts:30

How long the clip is, in seconds, or NaN until the element knows.


ended ​

ts
readonly ended: boolean;

Defined in: lib/lib-preview-player/src/player.ts:34

Whether the clip has run to its end.


error ​

ts
readonly error: unknown;

Defined in: lib/lib-preview-player/src/player.ts:36

What stopped the element playing the clip it holds, or null when nothing has: an element forgets it when it is given another clip.


paused ​

ts
readonly paused: boolean;

Defined in: lib/lib-preview-player/src/player.ts:32

Whether the element is not playing.


src ​

ts
src: string;

Defined in: lib/lib-preview-player/src/player.ts:24

The URL of the clip the element holds. Set to a track's clip before it is played.


volume ​

ts
volume: number;

Defined in: lib/lib-preview-player/src/player.ts:28

How loud, from 0 to 1. Set by setVolume.

Methods ​

addEventListener() ​

ts
addEventListener(type, listener): void;

Defined in: lib/lib-preview-player/src/player.ts:62

Hears an event of the element. The player listens for playing, pause, waiting, timeupdate, durationchange, volumechange, ended and error, from when it is made until it is disposed.

Parameters ​

type ​

string

The event's name.

listener ​

() => void

What to call when it fires.

Returns ​

void


load() ​

ts
load(): void;

Defined in: lib/lib-preview-player/src/player.ts:48

With removeAttribute("src"), how a clip is taken off the element, so that it holds nothing of a queue that is gone.

Returns ​

void


pause() ​

ts
pause(): void;

Defined in: lib/lib-preview-player/src/player.ts:46

Stops playing, keeping the clip and the position in it.

Returns ​

void


play() ​

ts
play(): Promise<void>;

Defined in: lib/lib-preview-player/src/player.ts:44

Starts playing the clip under src, and settles as HTMLMediaElement.play() does: once playing has begun, or with why it will not.

Returns ​

Promise<void>

Throws ​

The element's own refusal, as a rejection: a browser that will not start sound without a click behind it rejects with its NotAllowedError. The player hands it on to whoever called play, next or previous.


removeAttribute() ​

ts
removeAttribute(name): void;

Defined in: lib/lib-preview-player/src/player.ts:54

Takes an attribute off the element. The player calls it for "src" alone, before load().

Parameters ​

name ​

string

The attribute's name.

Returns ​

void


removeEventListener() ​

ts
removeEventListener(type, listener): void;

Defined in: lib/lib-preview-player/src/player.ts:69

Stops hearing an event: dispose takes off every listener addEventListener was given.

Parameters ​

type ​

string

The event's name.

listener ​

() => void

The function addEventListener was handed for it.

Returns ​

void

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.