useAudio
⚠️
If mic isn’t enabled in the lobby, audio won’t be shareable inside the room
⚠️
The method is to be called only when in lobby state.
These are the fields which are returned from useAudio
hook.
Name | Type | Description |
---|---|---|
fetchAudioStream(deviceId?: string) | Function | Enables audio stream from user’s device mic(lobby) |
stopAudioStream() | Function | Disables audio stream from user’s device mic(lobby) |
produceAudio() | Function | Starts sharing user’s webcam audio stream with other peers in the room |
stopProducingAudio() | Function | Stops sharing user’s webcam audio stream with other peers in the room |
isLoading | boolean | loading state |
isProducing | boolean | state whether the audio is producing or not |
stream | MediaStream | audio stream |
error | string | gives the error message |
Sample Code
import {Button, View} from 'react-native';
import { useAudio } from '@huddle01/react-native/hooks';
const App = () => {
const { fetchAudioStream, stopAudioStream, isProducing, stream, error} = useAudio();
return (
<View>
<View style={styles.button}>
<Button
title="FETCH_AUDIO_STREAM"
disabled={!fetchAudioStream.isCallable}
onPress={fetchAudioStream}
/>
</View>
<View style={styles.button}>
<Button
title="STOP_AUDIO_STREAM"
disabled={!stopAudioStream.isCallable}
onPress={stopAudioStream}
/>
</View>
</View>
);
};