Skip to content

AudioPlaylist: parameters

Evandro Leopoldino Gonçalves edited this page Nov 29, 2022 · 10 revisions
  • files: string[] | { [key: string]: number }
    If you pass files with a weighted structure, the playlist will be played in a loop and shuffled.
import { AudioPlaylist } from 'ts-audio';
import songOne from './1.mp3';
import songTwo from './2.mp3';
import songThree from './3.mp3'; 

const playlist = AudioPlaylist({
 files: { [songOne]: 1, [songTwo]: 5, [songThree]: 1 },
});

playlist.play(); // `songTwo` will play five times more often than `songOne` and `songTree`
  • volume?: number (Range 0-1, 1 by default)

  • loop?: boolean (false by default)

  • preload?: boolean (false by default)

  • preloadLimit?: number (3 by default) Defines the maximum number of files that will be requested concurrently

  • shuffle?: boolean (false by default)
    Shuffles the order of all files passed by parameter before playing them.

Clone this wiki locally