mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-22 00:34:43 +01:00
Completed subtitle feature
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user