mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
fix: iOS only supports vtt captions
This commit is contained in:
@@ -4,7 +4,7 @@ import type {
|
||||
TextTracks,
|
||||
} from "react-native-video";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { ActivityIndicator, View } from "react-native";
|
||||
import { ActivityIndicator, Platform, View } from "react-native";
|
||||
import Video, { TextTracksType } from "react-native-video";
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
@@ -173,10 +173,16 @@ const captionTypeToTextTracksType = {
|
||||
};
|
||||
|
||||
function convertCaptionsToTextTracks(captions: Caption[]): TextTracks {
|
||||
return captions.map((caption) => ({
|
||||
title: caption.language,
|
||||
language: caption.language as ISO639_1,
|
||||
type: captionTypeToTextTracksType[caption.type] || TextTracksType.VTT,
|
||||
uri: caption.url,
|
||||
}));
|
||||
return captions.map((caption) => {
|
||||
if (Platform.OS === "ios" && caption.type !== "vtt") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
title: caption.language,
|
||||
language: caption.language as ISO639_1,
|
||||
type: captionTypeToTextTracksType[caption.type],
|
||||
uri: caption.url,
|
||||
};
|
||||
}).filter(Boolean) as TextTracks;
|
||||
}
|
||||
|
Reference in New Issue
Block a user