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.

NameTypeDescription
fetchAudioStream(deviceId?: string)FunctionEnables audio stream from user’s device mic(lobby)
stopAudioStream()FunctionDisables audio stream from user’s device mic(lobby)
produceAudio()FunctionStarts sharing user’s webcam audio stream with other peers in the room
stopProducingAudio()FunctionStops sharing user’s webcam audio stream with other peers in the room
isLoadingbooleanloading state
isProducingbooleanstate whether the audio is producing or not
streamMediaStreamaudio stream
errorstringgives 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>
  );
};
 
 
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2022 Graphene 01, Inc. All Rights Reserved.