From a6943fc55b149897ba8cdaad85c236272bbfd4cd Mon Sep 17 00:00:00 2001 From: Rob Walch Date: Thu, 8 Oct 2020 18:05:27 -0400 Subject: [PATCH] Fix test failing with #3063 --- src/controller/subtitle-stream-controller.js | 2 +- tests/unit/controller/subtitle-stream-controller.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controller/subtitle-stream-controller.js b/src/controller/subtitle-stream-controller.js index 6d4984ce04e..360a2e2db6c 100644 --- a/src/controller/subtitle-stream-controller.js +++ b/src/controller/subtitle-stream-controller.js @@ -264,7 +264,7 @@ export class SubtitleStreamController extends BaseStreamController { onMediaSeeking () { if (this.fragCurrent) { - const currentTime = this.media ? this.media.currentTime : null; + const currentTime = this.media ? this.media.currentTime : 0; const tolerance = this.config.maxFragLookUpTolerance; const fragStartOffset = this.fragCurrent.start - tolerance; const fragEndOffset = this.fragCurrent.start + this.fragCurrent.duration + tolerance; diff --git a/tests/unit/controller/subtitle-stream-controller.js b/tests/unit/controller/subtitle-stream-controller.js index 37c33a13887..27ec3f85952 100644 --- a/tests/unit/controller/subtitle-stream-controller.js +++ b/tests/unit/controller/subtitle-stream-controller.js @@ -130,7 +130,8 @@ describe('SubtitleStreamController', function () { }); describe('onMediaSeeking', function () { - it('nulls fragPrevious', function () { + it('nulls fragPrevious when seeking away from fragCurrent', function () { + subtitleStreamController.fragCurrent = { start: 1000, duration: 10 }; subtitleStreamController.fragPrevious = {}; subtitleStreamController.onMediaSeeking(); expect(subtitleStreamController.fragPrevious).to.not.exist;