mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:33:26 +00:00
feat: play video via url
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import * as Haptics from "expo-haptics";
|
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 * as ScreenOrientation from "expo-screen-orientation";
|
||||||
import { useTheme, View } from "tamagui";
|
import { useTheme, View } from "tamagui";
|
||||||
|
|
||||||
@@ -11,20 +13,21 @@ import TabBarIcon from "~/components/TabBarIcon";
|
|||||||
export default function TabLayout() {
|
export default function TabLayout() {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
// const url = Linking.useURL();
|
const router = useRouter();
|
||||||
// const router = useRouter();
|
|
||||||
//
|
useEffect(() => {
|
||||||
// if (url) {
|
const handleOpenURL = (event: Linking.EventType) => {
|
||||||
// const { hostname, queryParams } = Linking.parse(url);
|
const { hostname, queryParams } = Linking.parse(event.url);
|
||||||
//
|
if (hostname === "media") {
|
||||||
// switch (hostname) {
|
router.push({
|
||||||
// case "media":
|
pathname: "/videoPlayer",
|
||||||
// return router.push({
|
params: { data: JSON.stringify(queryParams) },
|
||||||
// pathname: "/videoPlayer",
|
});
|
||||||
// params: { data: JSON.stringify(queryParams) }
|
}
|
||||||
// });
|
};
|
||||||
// }
|
|
||||||
// }
|
Linking.addEventListener("url", handleOpenURL);
|
||||||
|
}, [router]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
|
import * as Linking from "expo-linking";
|
||||||
import { Link, Stack } from "expo-router";
|
import { Link, Stack } from "expo-router";
|
||||||
import { Text, View } from "tamagui";
|
import { Text, View } from "tamagui";
|
||||||
|
|
||||||
export default function NotFoundScreen() {
|
export default function NotFoundScreen() {
|
||||||
|
if (Linking.useURL()) return null;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen options={{ title: "Oops!" }} />
|
<Stack.Screen options={{ title: "Oops!" }} />
|
||||||
|
@@ -14,13 +14,21 @@ export const BackButton = () => {
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
dismissFullscreenPlayer()
|
dismissFullscreenPlayer()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
router.back();
|
if (router.canGoBack()) {
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
router.replace("/");
|
||||||
|
}
|
||||||
return setTimeout(() => {
|
return setTimeout(() => {
|
||||||
Keyboard.dismiss();
|
Keyboard.dismiss();
|
||||||
}, 100);
|
}, 100);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
router.back();
|
if (router.canGoBack()) {
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
router.replace("/");
|
||||||
|
}
|
||||||
return setTimeout(() => {
|
return setTimeout(() => {
|
||||||
Keyboard.dismiss();
|
Keyboard.dismiss();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
Reference in New Issue
Block a user