Offset on sounds api
This commit is contained in:
@@ -134,6 +134,11 @@ class WebVoice implements Voice {
|
||||
this.ended = true;
|
||||
return;
|
||||
}
|
||||
// played with an offset past its end, it would have finished already
|
||||
if (!settings.loop && settings.offset >= buffer.duration) {
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
const source = new AudioBufferSourceNode(context, {
|
||||
buffer,
|
||||
loop: settings.loop,
|
||||
@@ -144,7 +149,7 @@ class WebVoice implements Voice {
|
||||
this.ended = true;
|
||||
this.#disconnect();
|
||||
};
|
||||
source.start(0, settings.loop ? settings.offset % buffer.duration : 0);
|
||||
source.start(0, settings.offset % buffer.duration);
|
||||
this.#source = source;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user