EZ Web Audio / createTrack
Function: createTrack()
createTrack(
url):Promise<Track>
Defined in: index.ts:215
Create a Track from an audio file URL.
Track extends Sound with position tracking, pause/resume, and seeking. Use Track for music or longer audio where users need playback control. Unlike Sound, only one playback can be active at a time.
Parameters
url
string
URL to the audio file (local path, relative URL, or absolute URL)
Returns
Promise<Track>
Promise resolving to a Track instance
Throws
If the audio file cannot be loaded or decoded
Example
typescript
import { createTrack } from 'ez-web-audio'
const song = await createTrack('song.mp3')
song.play()
// Pause and resume
song.pause()
song.resume()
// Seek to 30 seconds
song.seek(30).as('seconds')
// Get current position
console.log(song.position.string) // '0:30'