react-native-nodemediaclient icon indicating copy to clipboard operation
react-native-nodemediaclient copied to clipboard

feat(ios): suppport capturing pictures when streaming

Open heuels opened this issue 5 years ago • 0 comments

Hey guys,

I saw a couple of issues raised about this, and though I don't urgently need it in my project I thought I'd go ahead and implement it. Unfortunately, I don't need to Android support in my project, so this PR is iOS-only.

Sample usage:

import React, { useCallback, useRef } from 'react';
import CameraRoll from '@react-native-community/cameraroll';
import { NodeCameraView } from 'react-native-nodemediaclient';

const CameraView = () => {
  const cameraRef = useRef(null);
  const setCameraRef = useCallback((node) => {
    cameraRef.current = node;
  }, []);

  const handleSomeButtonPress = useCallback(() => {
    cameraRef.current.capturePicture();
  }, []);

  return (
    <NodeCameraView
      // ...
      ref={setCameraRef}
      onCapturePicture={(picture) => {
        CameraRoll.save(`data:image/png;base64,${picture}`, { type: 'photo' });
      }}
    />
  );
};

Resolves #93.

heuels avatar Dec 05 '20 17:12 heuels