From d603f95720c3bcb5e35ff4405457be8292c3c589 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 24 May 2026 22:18:48 +0200 Subject: [PATCH] Cleanup view on web --- src/view.web.tsx | 62 +++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/src/view.web.tsx b/src/view.web.tsx index da59fe8..add167c 100644 --- a/src/view.web.tsx +++ b/src/view.web.tsx @@ -1,46 +1,28 @@ -import "@videojs/react/video/skin.css"; - -import { memo, useEffect, useRef } from "react"; import { Video } from "@videojs/react/video"; import type { CSSProperties } from "react"; -import { VideoPlayer, usePlayer } from "./provider.web"; +import { useRef } from "react"; +import { usePlayer, VideoPlayer } from "./provider.web"; import type { OmniViewProps } from "./types/view"; -export const OmniView = memo( - ({ - style, - autoplay, - autoPip, - }: OmniViewProps & { style: CSSProperties }) => { - const player = usePlayer(); - const containerRef = useRef(null); +export const OmniView = ({ + style, + autoplay, +}: OmniViewProps & { style: CSSProperties }) => { + const player = usePlayer(); + const containerRef = useRef(null); - useEffect(() => { - const media = containerRef.current?.querySelector("video"); - (player as any).setMediaElement(media ?? null); - }, []); + const src = player.source.src[0]?.uri; - useEffect(() => { - if (!autoPip) return; - const media = containerRef.current?.querySelector("video"); - if (media && document.pictureInPictureEnabled) { - media.requestPictureInPicture().catch(() => {}); - } - }, [autoPip]); - - const src = player.source.src[0]?.uri; - - return ( - - {src && ( - - ); - }, -); + return ( + + {src && ( + + ); +};