AgoraIO-Extensions/agora-rtc-react

How to identify track is normal video track or shared screen ?

Closed this issue · 2 comments

What kind of problem do you need help?

This hooks useRemoteUsers return remote users list with remote video track and shared screen track
const remoteUsers = useRemoteUsers();

How to identify track is normal video track or shared screen ?

@nileshzala005

check the sample code you can identify by UID.

Like @guoxianzhe mentioned, you can identify by UID.

Here is another creative approach. On your server, embed some information into the token to identify a screen share client and retrieve the token via UID. Decode and use it normally. Here is an example:

client.on("user-published", async (participant, mediaType) => {
    const remoteId = participant.uid as string;
    const clientData = decodeData(remoteId);

    if (clientData?.id !== user?.id) {
        await client.subscribe(participant, mediaType);

        if (mediaType === "audio") {
            participant.audioTrack?.play();
        }
    }

    if (clientData?.screen_share) { // Here I know it is a screen share client
        setHighlightedParticipant(remoteId);
    }
});

Here is a reference to see how this token can be created on the server:
#199 (comment)