From a5245393a9e77319f259ea76b7ca6287fba1addf Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Thu, 5 Dec 2024 09:22:12 +0200 Subject: [PATCH] FEC-14226: protect against missing textTracks in fast entry change (#800) ### Description of the Changes Please add a detailed description of the change, whether it's an enhancement or a bugfix. If the PR is related to an open issue please link to it. ### CheckLists - [x] changes have been done against master branch, and PR does not conflict - [-] new unit / functional tests have been added (whenever applicable) - [x] test are passing in local environment - [x] Travis tests are passing (or test results are not worse than on master branch :)) - [-] Docs have been updated --- src/player.ts | 2 +- src/track/external-captions-handler.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/player.ts b/src/player.ts index 25743cef..f936860e 100644 --- a/src/player.ts +++ b/src/player.ts @@ -2491,7 +2491,7 @@ export default class Player extends FakeEventTarget { * @private */ private _getTracksByType(type: { new (...args: any[]): T }): T[] { - return this._tracks.reduce((arr: T[], track) => { + return this._tracks?.reduce((arr: T[], track) => { if (track instanceof type && track.available) { arr.push(track); } diff --git a/src/track/external-captions-handler.ts b/src/track/external-captions-handler.ts index 1f70abdd..06d92295 100644 --- a/src/track/external-captions-handler.ts +++ b/src/track/external-captions-handler.ts @@ -502,7 +502,7 @@ class ExternalCaptionsHandler extends FakeEventTarget { * @private */ private _maybeSetExternalCueIndex(): boolean { - const textTrack = this._player._getTextTracks().find(track => track.active && track.external); + const textTrack = this._player._getTextTracks()?.find(track => track.active && track.external); if (textTrack && textTrack.external) { const cues = this._textTrackModel[textTrack.language] ? this._textTrackModel[textTrack.language].cues : []; let i = 0;