From f117548b386ef35337340b5362c5ef522caf7f59 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Mon, 5 Dec 2022 09:43:47 +0100 Subject: [PATCH] Do not resume voice broadcasts on seek (#9686) --- src/voice-broadcast/models/VoiceBroadcastPlayback.ts | 2 +- .../models/VoiceBroadcastPlayback-test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/voice-broadcast/models/VoiceBroadcastPlayback.ts b/src/voice-broadcast/models/VoiceBroadcastPlayback.ts index 70c7a4d82f..d21ca49e33 100644 --- a/src/voice-broadcast/models/VoiceBroadcastPlayback.ts +++ b/src/voice-broadcast/models/VoiceBroadcastPlayback.ts @@ -387,7 +387,7 @@ export class VoiceBroadcastPlayback const offsetInChunk = time - this.chunkEvents.getLengthTo(event); await skipToPlayback.skipTo(offsetInChunk / 1000); - if (currentPlayback !== skipToPlayback) { + if (this.state === VoiceBroadcastPlaybackState.Playing && !skipToPlayback.isPlaying) { await skipToPlayback.play(); } diff --git a/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts b/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts index 64fb2f095f..64b2362703 100644 --- a/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts +++ b/test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts @@ -407,6 +407,17 @@ describe("VoiceBroadcastPlayback", () => { describe("and calling stop", () => { stopPlayback(); itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped); + + describe("and skipping to somewhere in the middle of the first chunk", () => { + beforeEach(async () => { + mocked(chunk1Playback.play).mockClear(); + await playback.skipTo(1); + }); + + it("should not start the playback", () => { + expect(chunk1Playback.play).not.toHaveBeenCalled(); + }); + }); }); describe("and calling destroy", () => {