intro, map, layout, permissions
This commit is contained in:
1 parent
efdbbdfc76
commit
d9387f464f
16 files changed
+204
-131
No files matched your search
@@ -4,50 +4,38 @@ import ChargedButton from "../ChargedButton";
|
||||
import { usePermissions } from "@/hooks/usePermission";
|
||||
import styles from "@/css/Intro.module.css";
|
||||
import { InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import PermissionCheck from "../PermissionCheck";
|
||||
import { PermissionStateResult } from "@/utils/permissions";
|
||||
|
||||
export default function Intro() {
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const { gpsStatus, cameraStatus, refresh } = usePermissions();
|
||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||
|
||||
const requestGPSPermission = () => {
|
||||
navigator.geolocation.getCurrentPosition(() => refresh, () => refresh);
|
||||
}
|
||||
const requestCamPermission = () => {
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
"video": { facingMode: { ideal: "environment" } },
|
||||
"audio": false,
|
||||
}).then((stream) => {
|
||||
refresh();
|
||||
stream.getTracks().forEach(track => track.stop());
|
||||
alert("Keine Sorge! Die Kamera ist wieder ausgeschalten. Der Gerät zeigt Ihnen nur, dass darauf kurz zugegriffen wurde.");
|
||||
}).catch((e) => refresh);
|
||||
}
|
||||
const [ granted, setGranted ] = useState(false);
|
||||
|
||||
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
||||
e.currentTarget.play();
|
||||
return true;
|
||||
};
|
||||
|
||||
const handlePermissions = (gps: PermissionStateResult, cam: PermissionStateResult) => {
|
||||
setGranted(gps === "granted" && cam === "granted");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="screen-container">
|
||||
{ !rewatchScreen ?
|
||||
<div>
|
||||
<p>CODE EINGELÖST</p>
|
||||
<p>TON AN</p>
|
||||
<p>Für diese Tour werden extra Berechtigungen gebraucht.</p>
|
||||
<p>Kamera: {cameraStatus}</p>
|
||||
<p>GPS: {gpsStatus}</p>
|
||||
<br></br>
|
||||
<button onClick={requestGPSPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>GPS</button>
|
||||
<button onClick={requestCamPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>Cam</button>
|
||||
<button onClick={refresh} style={{marginBottom: "2rem", marginRight: "3rem"}}>Refresh</button>
|
||||
<PermissionCheck onRefresh={handlePermissions}></PermissionCheck>
|
||||
<br></br>
|
||||
<ChargedButton onAction={() => {
|
||||
setRewatchScreen(true);
|
||||
}} holdDuration={500} disabled={gpsStatus !== "granted" || cameraStatus !== "granted"}>
|
||||
}} holdDuration={500} disabled={!granted}>
|
||||
Video ansehen
|
||||
</ChargedButton>
|
||||
<div className={styles["overlay-video"]}>
|
||||
@@ -66,14 +54,23 @@ export default function Intro() {
|
||||
onEnded={() => setVideoEnded(true)}
|
||||
onAbort={() => setVideoEnded(true)}
|
||||
onError={() => setVideoEnded(true)}
|
||||
onPause={() => setVideoPaused(true)}
|
||||
onPlay={() => setVideoPaused(false)}
|
||||
onClick={handleVideoClick}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}}
|
||||
>
|
||||
<source src="/res/testvid.webm" type="video/webm"/>
|
||||
<source src="/res/intro/testvid.webm" type="video/webm"/>
|
||||
</video>
|
||||
{ !videoEnded && videoPaused ?
|
||||
<div className={styles["pause-screen"]}>
|
||||
<Image src="/icons/pause.svg" alt="Pause Icon" width={48} height={48}/>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
{ videoEnded ? <div className={styles["rewatch-controls"]}>
|
||||
<ChargedButton holdDuration={500} onAction={() => {
|
||||
if (introVideoRef.current) {
|
||||
|
||||
Reference in new issue
Block a user