-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bug where incorrect track was removed when stop/start in rapid s…
…uccession (#2805) This PR fixes a bug that caused looping Sound to be unstoppable when stopped then started in rapid succession. There were two issues, an errant await and not checking the result of an `indexOf` for -1
- Loading branch information
Showing
9 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Sound Loop Test</title> | ||
</head> | ||
<body> | ||
Stopping a looping sounds should stop all running tracks | ||
<script src="../../lib/excalibur.js"></script> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
|
||
var game = new ex.Engine({ | ||
width: 400, | ||
height: 400 | ||
}); | ||
|
||
var sound = new ex.Sound('./gba1complete.mp3'); | ||
sound.volume = .05; | ||
sound.loop = true; | ||
|
||
|
||
var loader = new ex.Loader(); | ||
loader.addResource(sound) | ||
|
||
class BaseScene extends ex.Scene { | ||
constructor(public name) { | ||
super(); | ||
} | ||
override onActivate(): void { | ||
console.log('activate', this.name); | ||
sound.play(); | ||
} | ||
override onDeactivate(): void { | ||
console.log('deactivate', this.name); | ||
sound.stop(); | ||
} | ||
} | ||
|
||
var scene1 = new BaseScene("scene1"); | ||
var scene22 = new BaseScene("scene2"); | ||
var scene3 = new BaseScene("scene3"); | ||
|
||
game.add('scene1', scene1); | ||
game.add('scene2', scene22); | ||
game.add('scene3', scene3); | ||
|
||
game.start(loader).then(() => { | ||
game.goToScene('scene1'); | ||
|
||
setTimeout(() => { | ||
game.goToScene('scene1'); | ||
sound.stop(); | ||
}, 1000) | ||
}); | ||
|
||
// going to the same scene again causes the sound to become unstoppable?!?! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters