feat: hls downloads

This commit is contained in:
Adrian Castro
2024-03-26 19:57:35 +01:00
parent 0566b5ba54
commit 1e704bcdd6
11 changed files with 241 additions and 40 deletions

View File

@@ -3,7 +3,7 @@ import React from "react";
import { ScrollView } from "react-native-gesture-handler";
import { useRouter } from "expo-router";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useTheme } from "tamagui";
import { useTheme, YStack } from "tamagui";
import { DownloadItem } from "~/components/DownloadItem";
import ScreenLayout from "~/components/layout/ScreenLayout";
@@ -29,28 +29,46 @@ const DownloadsScreen: React.FC = () => {
return (
<ScreenLayout>
<MWButton
type="secondary"
backgroundColor="$sheetItemBackground"
icon={
<MaterialCommunityIcons
name="download"
size={24}
color={theme.buttonSecondaryText.val}
/>
}
onPress={async () => {
const asset = await startDownload(
"https://samplelib.com/lib/preview/mp4/sample-5s.mp4",
"mp4",
).catch(console.error);
if (asset) {
handlePress(asset);
<YStack space={2} style={{ padding: 10 }}>
<MWButton
type="secondary"
backgroundColor="$sheetItemBackground"
icon={
<MaterialCommunityIcons
name="download"
size={24}
color={theme.buttonSecondaryText.val}
/>
}
}}
>
test download (mp4)
</MWButton>
onPress={async () => {
await startDownload(
"https://samplelib.com/lib/preview/mp4/sample-5s.mp4",
"mp4",
).catch(console.error);
}}
>
test download (mp4)
</MWButton>
<MWButton
type="secondary"
backgroundColor="$sheetItemBackground"
icon={
<MaterialCommunityIcons
name="download"
size={24}
color={theme.buttonSecondaryText.val}
/>
}
onPress={async () => {
await startDownload(
"http://sample.vodobox.com/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8",
"hls",
).catch(console.error);
}}
>
test download (hls)
</MWButton>
</YStack>
<ScrollView>
{downloads.map((item) => (
<DownloadItem