EZ Web Audio / createSound
Function: createSound()
createSound(
url):Promise<Sound>
Defined in: index.ts:182
Create a Sound from an audio file URL.
Sound is for one-shot audio playback (sound effects, UI sounds). Each call to .play() creates a new audio source, allowing overlapping playback. Use createTrack instead for music with pause/resume/seek.
Parameters
url
string
URL to the audio file (local path, relative URL, or absolute URL)
Returns
Promise<Sound>
Promise resolving to a Sound instance
Throws
If the audio file cannot be loaded or decoded
Example
typescript
import { createSound } from 'ez-web-audio'
const click = await createSound('click.mp3')
click.play()
// Sounds can overlap
click.play()
click.play()
// Control volume
click.changeGainTo(0.5)
click.play()