How to capture a playing video (ex: youtube video) inside react native view

56 Views Asked by At

I am currently using react-native-view-shot to capture the visible screen of my react-native app. It works well, except for videos. When I take a capture while there is a youtube video playing, the images comes out with the video blacked out. Is there any workaround for this?

I am using this function to take a capture

  import {captureScreen} from 'react-native-view-shot';
  
  const captureScreenAsBase64 = async () => {
    /*
      This function captures the screen and returns the base64 string of the image
    */
    try {
      const uri = await captureScreen({
        format: 'png',
        quality: 0.8,
      });

      const response = await fetch(uri);
      const imageData = await response.blob();
      const base64Data = await new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onloadend = () => {
          resolve(reader.result);
        };
        reader.onerror = reject;
        reader.readAsDataURL(imageData);
      });
      return base64Data;
    } catch (error) {
      console.error('Failed to capture screen:', error);
      return null;
    }
  };
0

There are 0 best solutions below