twilio / video-quickstart-js

A quickstart and code samples for Twilio Video JavaScript SDK. https://www.twilio.com/docs/video
Other
389 stars 337 forks source link

TrackName is not setting on ShareScreen Video Track. #137

Closed irshadhub closed 4 years ago

irshadhub commented 4 years ago

I want to set a track name for screen sharing video track.

In the below code, I mentioned track name as "screen" but it is not assigning to track.

Please help me with this, it very urgent for me to set a track name to identify screen share video track with an ongoing video conference.

function createScreenTrack(height, width) {

  if ( typeof navigator === 'undefined' || !navigator.mediaDevices || !navigator.mediaDevices.getDisplayMedia ) {
    return Promise.reject(new Error('getDisplayMedia is not supported'));
  }

  return navigator.mediaDevices.getDisplayMedia({
    video: {
      height: height,
      width: width,
      name: 'screen'
    }
  }).then(function(stream) {
    return new Video.LocalVideoTrack(stream.getVideoTracks()[0]);
  });
}

Image sample for more understanding:

1) Screenshare track name which needs to set.

share-screen-track-name2

2) Camera View track name for reference.

share-screen-track-name

manjeshbhargav commented 4 years ago

Hi @irshadhub ,

You have to specify the name in the options for the LocalVideoTrack constructor and not in getDisplayMedia:

return navigator.mediaDevices.getDisplayMedia({
    video: {
      height: height,
      width: width
    }
  }).then(function(stream) {
    return new Video.LocalVideoTrack(stream.getVideoTracks()[0], { name: 'screen' });
  });
irshadhub commented 4 years ago

Thanks Manjesh, it is working perfectly now.