From 25979b66c7cca179cb7b92004a4e54da98ad5e66 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Mon, 19 Dec 2022 13:19:12 +0100 Subject: [PATCH] Stop broadcast playback when stopping the broadcast --- src/voice-broadcast/models/VoiceBroadcastPlayback.ts | 2 +- test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/voice-broadcast/models/VoiceBroadcastPlayback.ts b/src/voice-broadcast/models/VoiceBroadcastPlayback.ts index 9ec50e094d2..412deac3a42 100644 --- a/src/voice-broadcast/models/VoiceBroadcastPlayback.ts +++ b/src/voice-broadcast/models/VoiceBroadcastPlayback.ts @@ -388,6 +388,7 @@ export class VoiceBroadcastPlayback public stop(): void { this.setState(VoiceBroadcastPlaybackState.Stopped); + this.getCurrentPlayback()?.stop(); this.currentlyPlaying = null; this.setPosition(0); } @@ -397,7 +398,6 @@ export class VoiceBroadcastPlayback if (this.getState() === VoiceBroadcastPlaybackState.Stopped) return; this.setState(VoiceBroadcastPlaybackState.Paused); - if (!this.currentlyPlaying) return; this.getCurrentPlayback()?.pause(); } diff --git a/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts b/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts index 759adf11283..616875816be 100644 --- a/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts +++ b/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts @@ -411,6 +411,10 @@ describe("VoiceBroadcastPlayback", () => { stopPlayback(); itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped); + it("should stop the playback", () => { + expect(chunk1Playback.stop).toHaveBeenCalled(); + }); + describe("and skipping to somewhere in the middle of the first chunk", () => { beforeEach(async () => { mocked(chunk1Playback.play).mockClear();