Display media of other peers
To access data and media of other peers, use the usePeers
hook.
It returns two properties, peers
and localPeer
.
They contain all the tracks of other peers and all the tracks of the local user, respectively.
Example of playing other peers' available media
import React from "react";
import { usePeers } from "@fishjam-cloud/react-client";
function Component() {
const { peers } = usePeers();
return (
<ul>
{peers.map(({ id, cameraTrack, microphoneTrack }) => (
<li key={id}>
<VideoRenderer stream={cameraTrack?.stream} />
<AudioPlayer stream={microphoneTrack?.stream} />
</li>
))}
</ul>
);
}