UNPKG

@huddle01/react

Version:

The Huddle01 React SDK offers a comprehensive suite of hooks, methods and event listeners that allow for seamless real-time audio and video communication with minimal coding required.

49 lines (47 loc) 1.29 kB
import { useHuddle01_default } from "./chunk-EWIULLG2.js"; // src/hooks/useLocalMedia.ts var useLocalMedia = () => { const { huddleClient } = useHuddle01_default(); const localPeer = huddleClient.localPeer; const fetchStream = async (data) => { const fetchedStream = await localPeer.deviceHandler.fetchStream({ mediaDeviceKind: data.mediaDeviceKind }); return fetchedStream; }; const fetchStreamByGroupId = async (data) => { const fetchedStream = await localPeer.deviceHandler.fetchStreamByGroupId({ groupId: data.groupId, mediaDeviceKind: data.mediaDeviceKind }); return fetchedStream; }; const produceStream = (data) => { const producing = localPeer.produce({ label: data.label, stream: data.stream, appData: data.appData }); return producing; }; const stopProducing = (label) => { const stoppedProducing = localPeer.stopProducing({ label }); return stoppedProducing; }; const replaceStream = async (label, newStream) => { return await localPeer.replaceStream({ label, newStream }); }; return { fetchStream, fetchStreamByGroupId, replaceStream, produceStream, stopProducing }; }; export { useLocalMedia }; //# sourceMappingURL=chunk-WMIUY6Z4.js.map