tjallingt/react-youtube

I cannot play video with playVideo() in iOS Webview.

Opened this issue · 2 comments

I want to play Youtube video when be isIntersecting.

is working in iOS Safari, Android Webview, but not working in iOS Webview.
in iOS Webview, it seems to play and then immediately stop.

Has anyone experienced anything related?

code on Flutter Webview with React(18.1.9), react-youtube(10.0.0)

// YoutubePlayer.tsx
const onIntersect = useCallback(async ([entry] /*, observer */) => {
  if (entry.isIntersecting) {
    youtubeRef?.current?.internalPlayer?.playVideo();
    return;
  }
  youtubeRef?.current?.internalPlayer?.stopVideo();
}, []);

// ...

useEffect(() => {
  if (!opts || !onIntersect || !wrapperRef.current) {
    return;
  }
  const observer = new IntersectionObserver(onIntersect, {
    threshold: 0.5,
  });
  observer.observe(wrapperRef.current);
  return () => observer.disconnect();
}, [opts, onIntersect]);

Did you resolve this?
I made to play them when mute is set to true but no way to play them unmuted ...

I guess you can't do this if rely to official documentation