fix video web
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { Portal } from "@gorhom/portal";
|
||||
import { Asset } from "expo-asset";
|
||||
|
||||
import { videos } from "../assets";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
|
||||
const overlayStyle = {
|
||||
position: "fixed",
|
||||
@@ -58,8 +57,6 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
const [uri, setUri] = useState(null);
|
||||
const [muted, setMuted] = useState(false);
|
||||
|
||||
const resolvedSource = useMemo(() => url ?? videos.test, [url]);
|
||||
|
||||
useEffect(() => {
|
||||
let isMounted = true;
|
||||
|
||||
@@ -70,8 +67,8 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof resolvedSource === "string") {
|
||||
assignUri(resolvedSource);
|
||||
if (typeof url === "string") {
|
||||
assignUri(url);
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
@@ -79,7 +76,7 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
|
||||
const load = async () => {
|
||||
try {
|
||||
const nextUri = await resolveModuleUri(resolvedSource);
|
||||
const nextUri = await resolveModuleUri(url);
|
||||
assignUri(nextUri);
|
||||
} catch {
|
||||
if (isMounted) {
|
||||
@@ -93,7 +90,7 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [resolvedSource]);
|
||||
}, [url]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!visible) {
|
||||
@@ -148,24 +145,27 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
console.log("video uri", uri);
|
||||
return (
|
||||
<View pointerEvents="box-none" style={overlayStyle}>
|
||||
{uri ? (
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={uri}
|
||||
style={videoStyle}
|
||||
playsInline
|
||||
autoPlay
|
||||
loop={false}
|
||||
muted={muted}
|
||||
controls={false}
|
||||
/>
|
||||
) : null}
|
||||
<Pressable onPress={() => onClose?.()} style={closeButtonStyle}>
|
||||
<Text style={closeTextStyle}>Passer la vidéo</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
<Portal>
|
||||
<View pointerEvents="box-none" style={overlayStyle}>
|
||||
{uri ? (
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={uri}
|
||||
style={videoStyle}
|
||||
playsInline
|
||||
autoPlay
|
||||
loop={false}
|
||||
muted={muted}
|
||||
controls={false}
|
||||
/>
|
||||
) : null}
|
||||
<Pressable onPress={() => onClose?.()} style={closeButtonStyle}>
|
||||
<Text style={closeTextStyle}>Passer la vidéo</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</Portal>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user