🎥 Make videos programmatically with React
fix demo on iphone
Jonny Burgerd6a07854d538
diff --git a/packages/three/src/use-video-texture.ts b/packages/three/src/use-video-texture.tsindex 887f44eaed..f5c89fc430 100644--- a/packages/three/src/use-video-texture.ts+++ b/packages/three/src/use-video-texture.ts@@ -10,6 +10,19 @@ declare global {export type UseVideoTextureOptions = React.ComponentProps<typeof Video>;+let warned = false;++const warnAboutRequestVideoFrameCallback = () => {+ if (warned) {+ return false;+ }++ warned = true;+ console.warn(+ 'Browser does not support requestVideoFrameCallback. Cannot display video.'+ );+};+export const useVideoTexture = (videoRef: React.RefObject<HTMLVideoElement>): VideoTexture | null => {@@ -57,9 +70,8 @@ export const useVideoTexture = (}if (!current.requestVideoFrameCallback) {- throw new Error(- 'HTMLVideoElement.requestVideoFrameCallback not supported'- );+ warnAboutRequestVideoFrameCallback();+ return;}const ready = () => {@@ -70,5 +82,9 @@ export const useVideoTexture = (current.requestVideoFrameCallback(ready);}, [frame, loaded, videoRef]);+ if (!HTMLVideoElement.prototype.requestVideoFrameCallback) {+ return null;+ }+return videoTexture;};