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

When stopping a broadcast also stop the playback #9795

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary check

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