Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Stop broadcast playback when stopping the broadcast (#9795)
Browse files Browse the repository at this point in the history
  • Loading branch information
weeman1337 authored Dec 19, 2022
1 parent c0e0078 commit 2152f2a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/voice-broadcast/models/VoiceBroadcastPlayback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class VoiceBroadcastPlayback

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

this.setState(VoiceBroadcastPlaybackState.Paused);
if (!this.currentlyPlaying) return;
this.getCurrentPlayback()?.pause();
}

Expand Down
4 changes: 4 additions & 0 deletions test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2152f2a

Please sign in to comment.