Hiyve Components - v1.0.0
    Preparing search index...

    Function useLocalStream

    • Access the local camera MediaStream for rendering in an RTCView.

      A convenience hook that returns only the local stream, without the additional media state and actions provided by useLocalMedia. Useful when you only need to display the local video preview.

      Returns MediaStream | null

      The local camera MediaStream, or null if the camera has not been started

      This hook is React Native-specific. On web, the local stream is accessed via useLocalMedia(). In React Native, the returned MediaStream is intended for use with react-native-webrtc's RTCView component via its toURL() method.

      import { useLocalStream } from '@hiyve/rn-react';
      import { RTCView } from 'react-native-webrtc';

      function LocalPreview() {
      const localStream = useLocalStream();

      if (!localStream) return <Text>Camera not started</Text>;

      return (
      <RTCView
      streamURL={localStream.toURL()}
      style={{ width: 200, height: 150 }}
      objectFit="cover"
      mirror
      />
      );
      }