createSoundsfunction
A player for the sounds, which makes its audio only when first asked to play, as browsers insist on a gesture first. Plays nothing where there is no audio.
Import it
import { createSounds } from "@johnmorrisdotca/sugoroku/play";
Definition
function createSounds(urls: SoundUrls): SoundPlayer
Parameters
| Name | Type | Description |
|---|---|---|
urls | Partial<Record<SoundName, string>> | Optional URLs of the native board sounds. |
Returns
SoundPlayer
A player for the sounds, which makes its audio only when first asked to play, as browsers insist on a gesture first. Plays nothing where there is no audio.
Examples
import { legalPlaysOf, newGame, rollOpening, settingsFor } from "@johnmorrisdotca/sugoroku";
import { createSounds } from "@johnmorrisdotca/sugoroku/play";
const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
const play = legalPlaysOf(game)[0];
const sounds = createSounds({});
console.log(typeof sounds.play);
sounds.destroy();