Stop broadcast playback when stopping the broadcast (#9795)

pull/28217/head
Michael Weimann 2022-12-19 17:05:34 +01:00 committed by GitHub
parent c0e0078b6e
commit 2152f2ab8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -388,6 +388,7 @@ export class VoiceBroadcastPlayback
public stop(): void { public stop(): void {
this.setState(VoiceBroadcastPlaybackState.Stopped); this.setState(VoiceBroadcastPlaybackState.Stopped);
this.getCurrentPlayback()?.stop();
this.currentlyPlaying = null; this.currentlyPlaying = null;
this.setPosition(0); this.setPosition(0);
} }
@ -397,7 +398,6 @@ export class VoiceBroadcastPlayback
if (this.getState() === VoiceBroadcastPlaybackState.Stopped) return; if (this.getState() === VoiceBroadcastPlaybackState.Stopped) return;
this.setState(VoiceBroadcastPlaybackState.Paused); this.setState(VoiceBroadcastPlaybackState.Paused);
if (!this.currentlyPlaying) return;
this.getCurrentPlayback()?.pause(); this.getCurrentPlayback()?.pause();
} }

View File

@ -411,6 +411,10 @@ describe("VoiceBroadcastPlayback", () => {
stopPlayback(); stopPlayback();
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped); itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped);
it("should stop the playback", () => {
expect(chunk1Playback.stop).toHaveBeenCalled();
});
describe("and skipping to somewhere in the middle of the first chunk", () => { describe("and skipping to somewhere in the middle of the first chunk", () => {
beforeEach(async () => { beforeEach(async () => {
mocked(chunk1Playback.play).mockClear(); mocked(chunk1Playback.play).mockClear();