react-youtube icon indicating copy to clipboard operation
react-youtube copied to clipboard

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

Open ParkDyel opened this issue 3 years ago • 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]);

ParkDyel avatar Nov 08 '22 04:11 ParkDyel

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

LauraPiccolo avatar Jan 20 '23 15:01 LauraPiccolo

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

karakauer avatar Jan 23 '23 11:01 karakauer