react-native-nodemediaclient
react-native-nodemediaclient copied to clipboard
feat(ios): suppport capturing pictures when streaming
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.