From eaf62c92a76a23daf629aa77c86c4836530a3cf1 Mon Sep 17 00:00:00 2001 From: Felix Boehme Date: Thu, 31 Aug 2023 23:38:26 +0200 Subject: [PATCH] Use data url --- .../state/providers/castingStateProvider.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/video/state/providers/castingStateProvider.ts b/src/video/state/providers/castingStateProvider.ts index 8c7f5746..3914d8ea 100644 --- a/src/video/state/providers/castingStateProvider.ts +++ b/src/video/state/providers/castingStateProvider.ts @@ -148,12 +148,26 @@ export function createCastingStateProvider( let captions = null; - if (state.source?.caption?.url) { + if (state.source?.caption?.id) { + let captionIndex: number | undefined; + const linkedCaptions = state.meta?.captions; + const captionId = state.source?.caption?.id; + let trackContentId = ""; + + if (linkedCaptions) { + linkedCaptions.forEach((caption, index) => { + if (!captionIndex && captionId.includes(caption.langIso)) + captionIndex = index; + }); + if (captionIndex) { + trackContentId = linkedCaptions[captionIndex].url; + } + } const subtitles = new chrome.cast.media.Track( 1, chrome.cast.media.TrackType.TEXT ); - subtitles.trackContentId = state.source?.caption?.url; + subtitles.trackContentId = trackContentId; subtitles.trackContentType = "text/vtt"; subtitles.subtype = chrome.cast.media.TextTrackType.SUBTITLES; subtitles.name = "Subtitles";