mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:33:26 +00:00
fix: properly support opening video via url
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { useEffect } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import * as Haptics from "expo-haptics";
|
||||
import * as Linking from "expo-linking";
|
||||
import { Tabs, useRouter } from "expo-router";
|
||||
import { Tabs } from "expo-router";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
import { useTheme, View } from "tamagui";
|
||||
|
||||
@@ -12,23 +10,6 @@ import TabBarIcon from "~/components/TabBarIcon";
|
||||
|
||||
export default function TabLayout() {
|
||||
const theme = useTheme();
|
||||
|
||||
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
|
||||
sceneContainerStyle={{
|
||||
|
@@ -15,9 +15,16 @@ export default function VideoPlayerWrapper() {
|
||||
const { presentFullscreenPlayer } = usePlayer();
|
||||
|
||||
const params = useLocalSearchParams();
|
||||
const data = params.data
|
||||
? (JSON.parse(params.data as string) as Partial<ItemData>)
|
||||
: undefined;
|
||||
let data;
|
||||
if ("data" in params) {
|
||||
if (typeof params.data === "string") {
|
||||
data = JSON.parse(params.data) as Partial<ItemData>;
|
||||
} else {
|
||||
data = undefined;
|
||||
}
|
||||
} else {
|
||||
data = params as Partial<ItemData>;
|
||||
}
|
||||
const media = params.media
|
||||
? (JSON.parse(params.media as string) as ScrapeMedia)
|
||||
: undefined;
|
||||
|
Reference in New Issue
Block a user