From 04f67df289ed731b3576e563d0d889db95e72333 Mon Sep 17 00:00:00 2001 From: Felix Boehme Date: Fri, 1 Sep 2023 15:03:10 +0200 Subject: [PATCH] cleaned up --- src/video/state/providers/castingStateProvider.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/video/state/providers/castingStateProvider.ts b/src/video/state/providers/castingStateProvider.ts index 3914d8ea..633a3ca2 100644 --- a/src/video/state/providers/castingStateProvider.ts +++ b/src/video/state/providers/castingStateProvider.ts @@ -151,14 +151,16 @@ export function createCastingStateProvider( if (state.source?.caption?.id) { let captionIndex: number | undefined; const linkedCaptions = state.meta?.captions; - const captionId = state.source?.caption?.id; + const captionLangIso = state.source?.caption?.id.slice(7); let trackContentId = ""; if (linkedCaptions) { - linkedCaptions.forEach((caption, index) => { - if (!captionIndex && captionId.includes(caption.langIso)) + for (let index = 0; index < linkedCaptions.length; index += 1) { + if (captionLangIso === linkedCaptions[index].langIso) { captionIndex = index; - }); + break; + } + } if (captionIndex) { trackContentId = linkedCaptions[captionIndex].url; }