MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / constructor

Method constructor

modules/piu/MC/piuSound.js:62–80  ·  view source on GitHub ↗
(it)

Source from the content-addressed store, hash-verified

60 this.private.volume = Math.round(it * 256);
61 }
62 constructor(it) {
63 if (Array.isArray(it)) {
64 this.tones = it;
65 return;
66 }
67
68 let archive = it.archive;
69 let path = it.path;
70 if (!path)
71 throw new URIError("Sound: no path!");
72 if (!path.endsWith(".wav"))
73 throw new URIError("Sound: not .wav!");
74 path = path.slice(0, -4) + ".maud";
75 if (!Resource.exists(path, archive))
76 throw new URIError("Sound: " + it.path + " not found!");
77 this.buffer = new Resource(path, archive);
78 this.offset = it.offset ?? 0;
79 this.size = it.size ?? -1;
80 }
81 play(stream = 0, repeat = 1, callback) {
82 const audioOut = Sound.private.audioOut ?? Sound.open();
83 audioOut.enqueue(stream, AudioOut.Flush);

Callers

nothing calls this directly

Calls 2

sliceMethod · 0.65
existsMethod · 0.65

Tested by

no test coverage detected