From 26392c29a7ad6da940770a7060da65300989e854 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Sun, 25 Jul 2021 08:43:18 -0700 Subject: [PATCH] Adding Players.add example Fixes #916 --- Tone/source/buffer/Players.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tone/source/buffer/Players.ts b/Tone/source/buffer/Players.ts index ddfc71c4..4a5ac9ca 100644 --- a/Tone/source/buffer/Players.ts +++ b/Tone/source/buffer/Players.ts @@ -202,6 +202,12 @@ export class Players extends ToneAudioNode { * @param name A unique name to give the player * @param url Either the url of the bufer or a buffer which will be added with the given name. * @param callback The callback to invoke when the url is loaded. + * @example + * const players = new Tone.Players(); + * players.add("gong", "https://tonejs.github.io/audio/berklee/gong_1.mp3", () => { + * console.log("gong loaded"); + * players.get("gong").start(); + * }); */ add(name: string, url: string | ToneAudioBuffer | AudioBuffer, callback?: () => void): this { assert(!this._buffers.has(name), "A buffer with that name already exists on this object");