Skip to content

Commit c9ce9df

Browse files
authored
bug fix: zero duration sound (#243)
1 parent 1560bc1 commit c9ce9df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/bundles/sound/functions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ export function play_in_tab(sound: Sound): Sound {
347347
throw new Error(`${play_in_tab.name}: audio system still playing previous sound`);
348348
} else if (get_duration(sound) < 0) {
349349
throw new Error(`${play_in_tab.name}: duration of sound is negative`);
350+
} else if (get_duration(sound) === 0) {
351+
return sound;
350352
} else {
351353
// Instantiate audio context if it has not been instantiated.
352354
if (!audioplayer) {
@@ -417,6 +419,8 @@ export function play(sound: Sound): Sound {
417419
);
418420
} else if (get_duration(sound) < 0) {
419421
throw new Error(`${play.name}: duration of sound is negative`);
422+
} else if (get_duration(sound) === 0) {
423+
return sound;
420424
} else {
421425
// Instantiate audio context if it has not been instantiated.
422426
if (!audioplayer) {

src/bundles/stereo_sound/functions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ export function play_in_tab(sound: Sound): Sound {
382382
throw new Error(`${play_in_tab.name}: audio system still playing previous sound`);
383383
} else if (get_duration(sound) < 0) {
384384
throw new Error(`${play_in_tab.name}: duration of sound is negative`);
385+
} else if (get_duration(sound) === 0) {
386+
return sound;
385387
} else {
386388
// Instantiate audio context if it has not been instantiated.
387389
if (!audioplayer) {
@@ -478,6 +480,8 @@ export function play(sound: Sound): Sound {
478480
throw new Error(`${play.name}: audio system still playing previous sound`);
479481
} else if (get_duration(sound) < 0) {
480482
throw new Error(`${play.name}: duration of sound is negative`);
483+
} else if (get_duration(sound) === 0) {
484+
return sound;
481485
} else {
482486
// Instantiate audio context if it has not been instantiated.
483487
if (!audioplayer) {

0 commit comments

Comments
 (0)