Skip to content

Commit 8932661

Browse files
authored
fix(sounds): Clear all sounds on test finish (@Leonabcd123) (monkeytypegame#7196)
### Description Use `Howler.stop()` to stop all sounds after finishing a test. Closes monkeytypegame#7194
1 parent 64a0bdc commit 8932661

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

frontend/src/ts/controllers/sound-controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,11 @@ export async function playTimeWarning(): Promise<void> {
638638
soundToPlay.play();
639639
}
640640

641+
export async function clearAllSounds(): Promise<void> {
642+
const Howl = (await gethowler()).Howler;
643+
Howl.stop();
644+
}
645+
641646
function playNote(
642647
codeOverride?: string,
643648
oscillatorTypeOverride?: SupportedOscillatorTypes,

frontend/src/ts/test/test-logic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as CustomText from "./custom-text";
1212
import * as CustomTextState from "../states/custom-text-name";
1313
import * as TestStats from "./test-stats";
1414
import * as PractiseWords from "./practise-words";
15+
import * as SoundController from "../controllers/sound-controller";
1516
import * as ShiftTracker from "./shift-tracker";
1617
import * as AltTracker from "./alt-tracker";
1718
import * as Focus from "./focus";
@@ -296,6 +297,7 @@ export function restart(options = {} as RestartOptions): void {
296297
TestUI.reset();
297298
CompositionState.setComposing(false);
298299
CompositionState.setData("");
300+
void SoundController.clearAllSounds();
299301

300302
if (TestState.resultVisible) {
301303
if (Config.randomTheme !== "off") {

0 commit comments

Comments
 (0)