more fixes web + mobile
This commit is contained in:
@@ -9,6 +9,8 @@ import { Portal } from "@gorhom/portal";
|
||||
// - url?: string | number (require), source of the video. Defaults to videos.test
|
||||
// - visible?: boolean, when false returns null
|
||||
// - onClose: () => void, called when user skips or when video ends
|
||||
const CLOSE_THRESHOLD_SECONDS = 0.35;
|
||||
|
||||
const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
const source = url
|
||||
? typeof url === "string"
|
||||
@@ -61,7 +63,19 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
return;
|
||||
}
|
||||
const remaining = player.duration - currentTime;
|
||||
if (Number.isFinite(remaining) && remaining <= 0.1) {
|
||||
if (Number.isFinite(remaining) && remaining <= CLOSE_THRESHOLD_SECONDS) {
|
||||
handleClose();
|
||||
}
|
||||
}
|
||||
);
|
||||
const playingChangeSub = player.addListener?.(
|
||||
"playingChange",
|
||||
({ isPlaying } = {}) => {
|
||||
if (isPlaying || !player?.duration || hasClosedRef.current) {
|
||||
return;
|
||||
}
|
||||
const remaining = player.duration - (player.currentTime ?? 0);
|
||||
if (Number.isFinite(remaining) && remaining <= CLOSE_THRESHOLD_SECONDS) {
|
||||
handleClose();
|
||||
}
|
||||
}
|
||||
@@ -70,6 +84,7 @@ const FullscreenIntroVideo = ({ url, visible = true, onClose }) => {
|
||||
try {
|
||||
playToEndSub?.remove?.();
|
||||
timeUpdateSub?.remove?.();
|
||||
playingChangeSub?.remove?.();
|
||||
} catch (e) {}
|
||||
};
|
||||
}, [handleClose, player, visible]);
|
||||
|
||||
Reference in New Issue
Block a user