Manually subscribing and playing other users' video/audio tracks when joining a daily room.

We are building custom call application using daily-js.

We set subscribeToTracksAutomatically to false to manually make users subscribe to other users' media track.

We want each user to subscribe the owner of the call and up to three other users's video and audio when joining the room. How can I do so?


  • Lazer
    Lazer Dailynista
    edited August 2023

    Hi, @TomohiroMaeda!

    To do this, you'll use the updateParticipant() call object instance method and specify the setSubscribedTracks property (which can be used to set subscription state for either all tracks or take an object of specific track kinds to subscribe to.)

    So when the user joins the call, you'd use the participants list to get the session ID of the room owner and the three other participants you want to subscribe to, and subscribe to their tracks via that call. There are many different possible approaches to the participant selection itself. One example of subscribing to the owner might be listening for the "participant-joined" event (which will fire for every existing and new participant once a local participant joins the call) and using the participant's owner property to check if they're an owner or not. If it's true, you can subscribe.

    To use the tracks once the local participant is subscribed to them, I hope my blog post on working with participants' media tracks can be useful. Let me know if there's anything more I can help with.

  • @Lazer

    Thank you so much! We could make it work.

  • Lazer
    Lazer Dailynista

    Glad to hear it!

    Also sorry, I realized just now that I actually linked a post different from the one I was thinking of up above (but thankfully that one was still about track subscriptions, so I hope it still came in useful :D)

    But in regards to handling media tracks after subscribing, this is the post I was thinking of: