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;