Reputation: 2184
In my application i have a user that is simultaneously using two video tracks (screen sharing and a webcam). Firs when the user connects The webcam starts and then the screen sharing track gets added.
In the muddle of this session i need an ability to enable the user camera switching. I used this guide here to implement this feature: https://www.twilio.com/blog/2018/06/switching-cameras-twilio-video-chat.html
However when i do something like this:
const tracks = Array.from(localParticipant.videoTracks.values());
localParticipant.unpublishTracks(tracks);
localParticipant.publishTrack(localVideoTrack);
I unpublish both video tracks(screen sharing and camera) and only adding a camera track. Is there a way to add a property to the track(other than "kind") that will allow me to make this distinction? Because right now the only way i can do it is tracking if the user has screen sharing enabled and re-connect both tracks in this case.
Upvotes: 1
Views: 760
Reputation: 73065
Twilio developer evangelist here.
All Track
s within Twilio Video have a name
property which is the track ID by default. However, you can set the name
of the track when you create or publish it.
For example:
localParticipant.publishTrack(localVideoTrack, { name: "camera" }
You can then read the name from the LocalTrack
or RemoteTrack
object later.
Let me know if that helps.
Upvotes: 3