Skip to main content

Interface: AudioOptions

Defined in: types.ts:14

Configuration options for creating an audio track.

Example​

const audio = createAudio('music.mp3', {
id: 'bg-music',
volume: 0.7,
loop: true,
autoPlay: false,
});

Properties​

autoPlay?​

optional autoPlay: boolean

Defined in: types.ts:51

Auto-play on creation. Note: May be blocked by browser autoplay policies.

Default​

false

id?​

optional id: string

Defined in: types.ts:20

Unique identifier for the audio track. Required for save/load functionality. If not provided, a random ID will be generated.


loop?​

optional loop: boolean

Defined in: types.ts:32

Whether to loop the audio automatically.

Default​

false

muted?​

optional muted: boolean

Defined in: types.ts:44

Whether to start muted.

Default​

false

playbackRate?​

optional playbackRate: number

Defined in: types.ts:38

Playback rate multiplier (0.5 = half speed, 2.0 = double speed).

Default​

1.0

preload?​

optional preload: "metadata" | "auto" | "none"

Defined in: types.ts:60

Preload strategy for the audio file.

  • 'none': Don't preload
  • 'metadata': Preload only metadata
  • 'auto': Let browser decide

Default​

'metadata'

volume?​

optional volume: number

Defined in: types.ts:26

Initial volume level (0.0 to 1.0).

Default​

1.0