I'm using the following code to just get the media and publish the track:
const stream = await navigator.mediaDevices.getDisplayMedia();
let screenTrack = new Twilio.Video.LocalVideoTrack(stream.getTracks()[0]);
room.localParticipant.publishTrack(screenTrack);
screenTrack.once('stopped', () => {
room.localParticipant.unpublishTrack(screenTrack);
screenTrack.stop();
screenTrack = null;
});
and here's what I use when a track is added:
participant.on('trackAdded', track => {
let div = document.createElement("div");
let participantAttr = document.createAttribute("participant-sid");
participantAttr.value = `${participant.sid}`;
div.setAttributeNode(participantAttr);
document.getElementById('remote-media-div').appendChild(div);
div.appendChild(track.attach());
});
The problem is when the div (a new track) is added it has all the same attributes whether it is a screen or a webcam video and I can't differentiate between the two when I need to do stuff to the screen video using javascript.
How do I assign a special attribute (like screen=true) to the screen sharing div/video?