Skip to content

Instantly share code, notes, and snippets.

@vrajdesai78
Created June 20, 2023 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrajdesai78/4d75d9fef7329ad45a60101154043d4e to your computer and use it in GitHub Desktop.
Save vrajdesai78/4d75d9fef7329ad45a60101154043d4e to your computer and use it in GitHub Desktop.
import { useHuddle01 } from '@huddle01/react';
import { useLobby, useAudio, useVideo } from '@huddle01/react/hooks';
const App = () => {
const { initialize, isInitialized } = useHuddle01();
const { joinLobby } = useLobby();
const { fetchAudioStream, stopAudioStream, error: micError } = useAudio();
const { fetchVideoStream, stopVideoStream, error: camError } = useVideo();
// Show error if it exists
useEffect(() => {
// its preferable to use env vars to store projectId
initialize('YOUR_PROJECT_ID');
}, []);
return (
<div>{isInitialized ? 'Hello World!' : 'Please initialize'}
<button
disabled={joinLobby.isCallable}
onClick={() => joinLobby('YOUR_ROOM_ID');
}>
Join Lobby
</button>
{/* Mic */}
<button disabled={!fetchAudioStream.isCallable} onClick={fetchAudioStream}>
FETCH_AUDIO_STREAM
</button>
{/* Webcam */}
<button disabled={!fetchVideoStream.isCallable} onClick={fetchVideoStream}>
FETCH_VIDEO_STREAM
</button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment