With the recent changes in names like publishTrack from addTrack, I was hoping there will be a subscribeTrack in a future release.
Participants can choose to subscribe to only certain participants tracks so that we can reduce the bandwidth and CPU consumption.
This would help a lot with our business need.
Is there a plan to do this?
Yes, this is a long-term plan. We've been experimenting with REST API support for Track subscription, which we'll write more about when it's ready.
As far as Client-side support, we've also sketched out API additions to the RemoteTrackPublication class such that you can subscribe and unsubscribe. The end goal is to provide an API like the following:
participant.on('trackPublished', async publication => {
console.log(`Participant ${participant.sid} published Track ${publication.trackSid}`);
console.log('Attempting to subscribe to ${publication.trackSid}');
const track = await publication.subscribe();
console.log(`Subscribed to ${track.sid}`);
// Then, after some time...
console.log(`Unsubscribing from ${track.sid}`);
track.unsubscribe();
});
Additionally, we'd ship the ability to connect with a default subscription policy鈥攅ither "subscribe all" or "subscribe none"鈥攚hich would effect whether you subscribe to all Tracks by default or not (the above example assumes "subscribe none" by default).
Many applications will not need the ability to subscribe like this, so they'll be able to continue using the default "subscribe all" behavior and the existing "trackSubscribed" event ("trackSubscribed" replaces the now deprecated "trackAdded"):
participant.on('trackSubscribed', track => {
console.log(`Subscribed to ${track.sid}`);
// Then, after some time...
console.log(`Unsubscribing from ${track.sid}`);
track.unsubscribe();
})
The order of these events will always be
May I know when we can expect this in twilio-video.js?
Hi @markandrus, above plan sounds great. While we're waiting for subscribing and unsubscribing in twilio-video.js, is it already possible to use the REST API to do so? If so, could you point us in the right direction? Thanks!
Hi @anand-io , @embirico ,
As a first step in moving towards implementing Track Subscriptions, we have released twilio-video.[email protected], where you can choose to join a Room without having to subscribe to any Tracks from other RemoteParticipants. This option is great for use-cases where one Participant is only concerned with publishing media (live lecture, for example).
Please feel free to try it out and let me know if this is useful for you.
Thanks,
Manjesh Malavalli
JSDK Team
Most helpful comment
Yes, this is a long-term plan. We've been experimenting with REST API support for Track subscription, which we'll write more about when it's ready.
As far as Client-side support, we've also sketched out API additions to the RemoteTrackPublication class such that you can
subscribeandunsubscribe. The end goal is to provide an API like the following:Additionally, we'd ship the ability to connect with a default subscription policy鈥攅ither "subscribe all" or "subscribe none"鈥攚hich would effect whether you subscribe to all Tracks by default or not (the above example assumes "subscribe none" by default).
Many applications will not need the ability to subscribe like this, so they'll be able to continue using the default "subscribe all" behavior and the existing "trackSubscribed" event ("trackSubscribed" replaces the now deprecated "trackAdded"):
The order of these events will always be