github twilio/twilio-video.js 1.5.0

latest releases: 2.8.2-rc1, 2.28.2-rc1, 2.28.1...
6 years ago

1.5.0 (October 9, 2017)

New Features

  • You can now specify Track names. Refer to the Track name guide below for more
    information.

Bug Fixes

  • Fixed bug where RemoteTrack's "unsubscribed" event and RemoteParticipant's
    "trackUnsubscribed" event fired before the RemoteTrack was removed from the
    RemoteParticipant's tracks collections instead of after.

Track Name Guide

Setting Track names

There are a few different ways you can specify Track names. For example, you can
specify name as an audio or video constraint when calling any of
createLocalTracks, createLocalAudioTrack, createLocalVideoTrack, or
connect:

createLocalTracks({
  audio: { name: 'microphone' },
  video: { name: 'camera' }
});

createLocalAudioTrack({ name: 'microphone' });
createLocalVideoTrack({ name: 'camera' });

connect(token, {
  audio: { name: 'microphone' },
  video: { name: 'camera' }
});

These will create a LocalAudioTrack and a LocalVideoTrack with the names
"microphone" and "camera", respectively. If you have a reference to a
MediaStreamTrack, you can also pass the name to the LocalAudioTrack or
LocalVideoTrack constructor:

const localAudioTrack = new LocalAudioTrack(mediaStreamTrack1, { name: 'microphone' });
const localVideoTrack = new LocalVideoTrack(mediaStreamTrack2, { name: 'camera' });

Similarly, for LocalDataTracks:

const localDataTrack = new LocalDataTrack({ name: 'data' });

You can even pass these values if you use the MediaStreamTrack override for
publishTrack. For example:

room.localParticipant.publishTrack(mediaStreamTrack, { name: 'my-track' });

Please keep in mind:

  • If you do not specify a Track name, the Track's name will default to the
    LocalTrack ID.
  • A single Participant cannot have two Tracks published with the same name at a
    time.

Getting Track names

You can check a LocalTrack or RemoteTrack's name by querying it's name
property. For example,

participant.on('trackSubscribed', track => {
  console.log('Subscribed to Track "' + track.name + '"');
});

This can be useful, for example, for distinguishing between a RemoteVideoTrack
named "camera" and a RemoteVideoTrack named "screenshare".

Don't miss a new twilio-video.js release

NewReleases is sending notifications on new releases.