Completed subtitle feature

This commit is contained in:
Alex Kim
2024-12-12 04:23:09 +11:00
parent 3fb20a8ca2
commit 35fcb5ca0c
7 changed files with 137 additions and 190 deletions

View File

@@ -335,23 +335,20 @@ const Player = () => {
) || [];
// Get unique text-based subtitles because react-native-video removes hls text tracks duplicates.
const uniqueTextSubs = Array.from(
new Set(textSubs.map((sub) => sub.DisplayTitle))
).map((title) => textSubs.find((sub) => sub.DisplayTitle === title));
const matchingSubtitle = textSubs.find(
(sub) => sub?.Index === sourceSubtitleIndex
);
return (
uniqueTextSubs.findIndex(
(sub) => sub?.DisplayTitle === matchingSubtitle?.DisplayTitle
) ?? -1
);
if (!matchingSubtitle) return -1;
return textSubs.indexOf(matchingSubtitle);
};
useEffect(() => {
if (selectedTextTrack === undefined) {
const embeddedTrackIndex = getEmbeddedTrackIndex(subtitleIndex!);
// Most likely the subtitle is burned in.
if (embeddedTrackIndex === -1) return;
console.log(
"Setting selected text track",
subtitleIndex,