Interface

AudioPlay

:

play

(time?: number): void

Start playing audio.

since v3000.0

seek

(time: number): void

Seek time.

since v3000.0

stop

(): void

Stop the sound.

since v3001.0

paused

: boolean

If the sound is paused.

since v2000.1

speed

: number

Playback speed of the sound. 1.0 means normal playback speed, 2.0 means twice as fast.

detune

: number

Detune the sound. Every 100 means a semitone.

// tune down a semitone
music.detune = -100

// tune up an octave
music.detune = 1200

volume

: number

Volume of the sound. 1.0 means full volume, 0.5 means half volume.

pan

?: number

The stereo pan of the sound. -1.0 means fully from the left channel, 0.0 means centered, 1.0 means fully right. Defaults to 0.0.

loop

: boolean

If the audio should start again when it ends.

time

(): number

The current playing time (not accurate if speed is changed).

duration

(): number

The total duration.

onEnd

(action: () => void): KEventController

Register an event that runs when audio ends.

since v3000.0

then

(action: () => void): KEventController
kaplay logo

Layer

Miscalenous