Local media state for the current user's devices.
Tracks the mute/unmute state of local audio, video, and output, as well as screen sharing status.
Media control buttons:
function MediaControls() { const { isAudioMuted, isVideoMuted, isScreenSharing, toggleAudio, toggleVideo, startScreenShare, stopScreenShare } = useLocalMedia(); return ( <div> <button onClick={toggleAudio}> {isAudioMuted ? 'Unmute' : 'Mute'} </button> <button onClick={toggleVideo}> {isVideoMuted ? 'Start Video' : 'Stop Video'} </button> <button onClick={isScreenSharing ? stopScreenShare : startScreenShare}> {isScreenSharing ? 'Stop Share' : 'Share Screen'} </button> </div> );} Copy
function MediaControls() { const { isAudioMuted, isVideoMuted, isScreenSharing, toggleAudio, toggleVideo, startScreenShare, stopScreenShare } = useLocalMedia(); return ( <div> <button onClick={toggleAudio}> {isAudioMuted ? 'Unmute' : 'Mute'} </button> <button onClick={toggleVideo}> {isVideoMuted ? 'Start Video' : 'Stop Video'} </button> <button onClick={isScreenSharing ? stopScreenShare : startScreenShare}> {isScreenSharing ? 'Stop Share' : 'Share Screen'} </button> </div> );}
useLocalMedia for the hook to access and control local media
Whether local microphone is muted
Whether speaker/output is muted
Whether screen sharing is active
Whether local camera is muted/off
Local media state for the current user's devices.
Remarks
Tracks the mute/unmute state of local audio, video, and output, as well as screen sharing status.
Example
Media control buttons:
See
useLocalMedia for the hook to access and control local media