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:
@@ -46,7 +46,7 @@ const defineConfig = (): ExpoConfig => ({
|
|||||||
[
|
[
|
||||||
"expo-screen-orientation",
|
"expo-screen-orientation",
|
||||||
{
|
{
|
||||||
initialOrientation: "DEFAULT",
|
initialOrientation: "PORTRAIT_UP",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@@ -4,7 +4,7 @@ import type {
|
|||||||
TextTracks,
|
TextTracks,
|
||||||
} from "react-native-video";
|
} from "react-native-video";
|
||||||
import React, { useEffect, useState } from "react";
|
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 Video, { TextTracksType } from "react-native-video";
|
||||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||||
import * as ScreenOrientation from "expo-screen-orientation";
|
import * as ScreenOrientation from "expo-screen-orientation";
|
||||||
@@ -173,10 +173,16 @@ const captionTypeToTextTracksType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function convertCaptionsToTextTracks(captions: Caption[]): TextTracks {
|
function convertCaptionsToTextTracks(captions: Caption[]): TextTracks {
|
||||||
return captions.map((caption) => ({
|
return captions.map((caption) => {
|
||||||
title: caption.language,
|
if (Platform.OS === "ios" && caption.type !== "vtt") {
|
||||||
language: caption.language as ISO639_1,
|
return null;
|
||||||
type: captionTypeToTextTracksType[caption.type] || TextTracksType.VTT,
|
}
|
||||||
uri: caption.url,
|
|
||||||
}));
|
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