mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix fullscreen handling
This commit is contained in:
parent
7315d5f5a1
commit
b0eb8c3b42
@ -53,7 +53,9 @@ const publicProgressAtom = atom(0);
|
||||
export const volumeAtom = atom(100);
|
||||
export const mutedAtom = atom(false);
|
||||
|
||||
export const [_, fullscreenAtom] = bakedAtom(false, async (_, set, value, baker) => {
|
||||
export const [privateFullscreen, fullscreenAtom] = bakedAtom(
|
||||
false,
|
||||
async (_, set, value, baker) => {
|
||||
try {
|
||||
if (value) {
|
||||
await document.body.requestFullscreen();
|
||||
@ -65,7 +67,8 @@ export const [_, fullscreenAtom] = bakedAtom(false, async (_, set, value, baker)
|
||||
screen.orientation.unlock();
|
||||
}
|
||||
} catch {}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
let hls: Hls | null = null;
|
||||
|
||||
@ -77,7 +80,7 @@ export const Video = ({
|
||||
// const [playMode, setPlayMode] = useAtom(playModeAtom);
|
||||
|
||||
const ref = useRef<NativeVideo | null>(null);
|
||||
const [isPlaying, setPlay] = useAtom(playAtom);
|
||||
const isPlaying = useAtomValue(playAtom);
|
||||
const setLoad = useSetAtom(loadAtom);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
@ -95,6 +98,15 @@ export const Video = ({
|
||||
const volume = useAtomValue(volumeAtom);
|
||||
const isMuted = useAtomValue(mutedAtom);
|
||||
|
||||
const setFullscreen = useSetAtom(privateFullscreen);
|
||||
useEffect(() => {
|
||||
const handler = () => {
|
||||
setFullscreen(document.fullscreenElement != null);
|
||||
};
|
||||
document.addEventListener("fullscreenchange", handler);
|
||||
return () => document.removeEventListener("fullscreenchange", handler);
|
||||
});
|
||||
|
||||
// useEffect(() => {
|
||||
// setPlayMode(PlayMode.Direct);
|
||||
// }, [links, setPlayMode]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user