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

    Function useLocalMedia

    • Access local media state and controls.

      Provides the current mute/unmute status for audio, video, and output, along with toggle actions and the local camera stream.

      Returns {
          isAudioMuted: boolean;
          isOutputMuted: boolean;
          isScreenSharing: boolean;
          isVideoMuted: boolean;
          localStream: MediaStream | null;
          switchCamera: () => Promise<void>;
          toggleAudio: () => Promise<void>;
          toggleOutputMute: () => Promise<void>;
          toggleVideo: () => Promise<void>;
      }

      Object containing media state (isAudioMuted, isVideoMuted, isOutputMuted, isScreenSharing, localStream) and actions (toggleAudio, toggleVideo, switchCamera)

      • isAudioMuted: boolean
      • isOutputMuted: boolean
      • isScreenSharing: boolean
      • isVideoMuted: boolean
      • localStream: MediaStream | null
      • switchCamera: () => Promise<void>
      • toggleAudio: () => Promise<void>
      • toggleOutputMute: () => Promise<void>
      • toggleVideo: () => Promise<void>

      This hook extends the web useLocalMedia with React Native-specific features:

      • localStream is exposed directly for use with RTCView
      • switchCamera toggles between front and rear cameras
      • Screen sharing state (isScreenSharing) is read-only; screen sharing is not supported on React Native
      import { useLocalMedia } from '@hiyve/rn-react';

      function MediaControls() {
      const { isAudioMuted, isVideoMuted, toggleAudio, toggleVideo, switchCamera } = useLocalMedia();

      return (
      <View style={{ flexDirection: 'row' }}>
      <Button title={isAudioMuted ? 'Unmute' : 'Mute'} onPress={toggleAudio} />
      <Button title={isVideoMuted ? 'Camera On' : 'Camera Off'} onPress={toggleVideo} />
      <Button title="Flip Camera" onPress={switchCamera} />
      </View>
      );
      }