feat: play video via url

This commit is contained in:
Adrian Castro
2024-04-02 08:51:00 +02:00
parent 21169c6caa
commit df4fe312fc
3 changed files with 30 additions and 17 deletions

View File

@@ -1,6 +1,8 @@
import { useEffect } from "react";
import { Platform } from "react-native";
import * as Haptics from "expo-haptics";
import { Tabs } from "expo-router";
import * as Linking from "expo-linking";
import { Tabs, useRouter } from "expo-router";
import * as ScreenOrientation from "expo-screen-orientation";
import { useTheme, View } from "tamagui";
@@ -11,20 +13,21 @@ import TabBarIcon from "~/components/TabBarIcon";
export default function TabLayout() {
const theme = useTheme();
// const url = Linking.useURL();
// const router = useRouter();
//
// if (url) {
// const { hostname, queryParams } = Linking.parse(url);
//
// switch (hostname) {
// case "media":
// return router.push({
// pathname: "/videoPlayer",
// params: { data: JSON.stringify(queryParams) }
// });
// }
// }
const router = useRouter();
useEffect(() => {
const handleOpenURL = (event: Linking.EventType) => {
const { hostname, queryParams } = Linking.parse(event.url);
if (hostname === "media") {
router.push({
pathname: "/videoPlayer",
params: { data: JSON.stringify(queryParams) },
});
}
};
Linking.addEventListener("url", handleOpenURL);
}, [router]);
return (
<Tabs

View File

@@ -1,7 +1,9 @@
import * as Linking from "expo-linking";
import { Link, Stack } from "expo-router";
import { Text, View } from "tamagui";
export default function NotFoundScreen() {
if (Linking.useURL()) return null;
return (
<>
<Stack.Screen options={{ title: "Oops!" }} />