Skip to content

1681-engine / index / MusicChannel

Class: MusicChannel ​

Defined in: src/audio/music/MusicChannel.ts:16

One layer of music (the score, a place's ambience…): one looping track at a time, crossfaded when it changes, at its own level under the player's music volume.

Constructors ​

Constructor ​

ts
new MusicChannel(volume, makeVoice): MusicChannel;

Defined in: src/audio/music/MusicChannel.ts:21

Parameters ​

ParameterType
volume() => number
makeVoice(el) => MusicVoice

Returns ​

MusicChannel

Accessors ​

current ​

Get Signature ​

ts
get current(): string | null;

Defined in: src/audio/music/MusicChannel.ts:27

The url of the track playing (or fading in), if any.

Returns ​

string | null

Methods ​

dispose() ​

ts
dispose(): void;

Defined in: src/audio/music/MusicChannel.ts:77

Returns ​

void


pause() ​

ts
pause(): void;

Defined in: src/audio/music/MusicChannel.ts:73

Stops where it is (the app went to the background); refresh picks it up again.

Returns ​

void


play() ​

ts
play(url, options?): void;

Defined in: src/audio/music/MusicChannel.ts:32

Plays url, crossfading from what plays now; the track already playing only takes the new volume.

Parameters ​

ParameterType
urlstring
optionsMusicPlayOptions

Returns ​

void


refresh() ​

ts
refresh(): void;

Defined in: src/audio/music/MusicChannel.ts:65

Retries a start the browser refused, and follows the music volume.

Returns ​

void


stop() ​

ts
stop(fadeMs?): void;

Defined in: src/audio/music/MusicChannel.ts:59

Fades this channel out and stops it.

Parameters ​

ParameterTypeDefault value
fadeMsnumber1200

Returns ​

void

Released under the MIT License.