Use data url

This commit is contained in:
Felix Boehme 2023-08-31 23:38:26 +02:00
parent 2ecfe57a2e
commit eaf62c92a7
No known key found for this signature in database
GPG Key ID: 7EB0603E4E9642EA

View File

@ -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";