How do I get video track from participant's ID using daily-js?

We are building application where an owner chooses a participant. We have the participant's id but cannot get the video track from the participant.

The participant returns data that has video track entry, but it is empty. We could get the track of the participant through 'track-started' event.




  • Tamara
    Tamara Moderator, Dailynista admin

    Hi Tomo! Thank you for your question.
    We've got a great blog post on tracks and how to get them, shared here:

    I believe this has all the steps and information you need to solve your question, but please reach out if there's anything else we can help you with!

  • @TomohiroMaeda, although you did not say which environment you are developing in. Nonetheless, one way to do it using Daily React is to use the "useParticipantProperty" hook. If you're participant's id is session_id, then you could get audio and video as follows:

    import { useParticipantProperty } from '@daily-co/daily-react';

    const audio = useParticipantProperty(session_id, 'audio');

    const video= useParticipantProperty(session_id, 'video');

    "useParticipantProperty" hook combined with "useLocalSessionId" hook are powerful and easy hooks to use to extract vital info about your participants.

  • christian
    christian Dailynista

    @jekwempu Here's a small simplification for the case you mentioned, in case you didn't know:

    const [audio, video] = useParticipantProperty(session_id, ['audio', 'video']);

    You can subscribe to multiple properties with only a single instance of the hook, which should make your components a little bit more performant and cleaner to read ☺️

  • Thank you, @Christian for pointing that out. It's good to know.