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