From 69fc99f55c24efe858c1b14973549b5b87371653 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Wed, 12 Jun 2024 10:15:57 +0200 Subject: [PATCH 01/11] =?UTF-8?q?fix(=F0=9F=93=B8):=20load=20video=20metad?= =?UTF-8?q?ata=20on=20dedicated=20thread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/src/external/reanimated/useVideo.ts | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/package/src/external/reanimated/useVideo.ts b/package/src/external/reanimated/useVideo.ts index 0d9638e840..07dd104591 100644 --- a/package/src/external/reanimated/useVideo.ts +++ b/package/src/external/reanimated/useVideo.ts @@ -1,5 +1,5 @@ -import type { SharedValue, FrameInfo } from "react-native-reanimated"; -import { useEffect, useMemo } from "react"; +import { type SharedValue, type FrameInfo, createWorkletRuntime, runOnJS, runOnRuntime } from "react-native-reanimated"; +import { useEffect, useMemo, useState } from "react"; import { Skia } from "../../skia/Skia"; import type { SkImage, Video } from "../../skia/types"; @@ -53,11 +53,31 @@ const disposeVideo = (video: Video | null) => { video?.dispose(); }; +const runtime = createWorkletRuntime('video-metadata-runtime'); + +type VideoSource = string | null; + +const useVideoLoading = (source: VideoSource) => { + const [video, setVideo] = useState