Selective Consuming

Selective Consuming (Advanced)

Selective consuming is a feature that allows you to receive media streams inside a room, only from the peers that you want. This is useful when you want to mute someone in a meeting only for yourself, or turn off their incoming video, without it affecting other participants.

To enable selective consuming, you need to pass autoConsume: false inside options when you initialize the HuddleClient.

import { HuddleClient } from "@huddle01/react";
 
const huddleClient = new HuddleClient({
  projectId: env.NEXT_PUBLIC_PROJECT_ID,
  options: {
    activeSpeakers: {
      size: 8,
    },
    autoConsume: false, //this will enable selective consuming in your app
  },
});

As a result, whenever you join a room, you will not receive media streams from any peer automatically.

You can now selectively consume media streams from the peers you want, by calling the consume method on your localPeer object.

import { useHuddle01, usePeerIds } from "@huddle01/react/dist/hooks";
 
const { huddleClient } = useHuddle01();
const { peerIds } = usePeerIds();
 
async function selectivelyConsume() {
  await huddleClient.localPeer.consume({
    peerId: peerIds[0], //peerID of the remote peer you want to consume mediastream from
    label: "video", //"video" or "audio"
    appData: {},
  });
}

You're all set! Happy Hacking! 🎉

For more information, please refer to the React SDK Reference.

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.