useLocalMedia

The useLocalMedia hook exposes methods to fetch and produce streams of a local peer.

NameDescriptionReturn TypeParams
fetchStreamFetches a stream from the local peerPromise<MediaStream>mediaDeviceKind: "mic" | "cam"
produceStreamProduces a stream to the local peerPromise<Producer<AppData>>{stream: MediaStream; label: string; appData: AppData}
stopProducingStops producing a stream to the local peervoidlabel: string
const { fetchStream, produceStream, stopProducing } = useLocalMedia();
 
const fetchAudioStream = async () => {
  const stream = await fetchStream({
    mediaDeviceKind: 'mic'
  });
  return stream;
};
 
const produceAudioStream = async () => {
  const stream = await fetchAudioStream();
  await produceStream({
    stream,
    label: 'mic',
    appData: {}
  });
  return stream;
};
Audio/Video Infrastructure designed for developers to empower them to ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2024 Graphene 01, Inc. All Rights Reserved.