Twilio’s Programmable Video JavaScript SDK
new
operator have been removed. Please use the es6 classes that are exported in the Video
namespace. (VIDEO-10893)dscpTagging
has been removed. Use enableDscp
instead. (VIDEO-10893)eventListener
has been removed. You can listen for the signaling events by intercepting the Logger's messages as shown here. (VIDEO-10893)abortOnIceServersTimeout
and iceServersTimeout
have been removed. (VIDEO-10893)maxTracks
and renderDimensions
have been removed. (VIDEO-10893)mediaStreamTrack
's type, which is supposed to be MediaStreamTrack | null
. (VIDEO-10893)id
property has been removed from the LocalTrack classes. Use the name
property instead. (VIDEO-10893)trackId
and ssrc
properties have been removed from the TrackStats class. (VIDEO-10893)maxAudioBitrate
and maxVideoBitrate
properties in ConnectOptions and EncodingParameters now accept values in kiliobits per second (kbps), as opposed to bits per second (bps) earlier. (VIDEO-10893)maxSubscriptionBitrate
property in VideoBandwidthProfile now accepts values in kiliobits per second (kbps), as opposed to bits per second (bps) earlier. (VIDEO-10893)logLevel
has been removed. Use the Video.Logger
interface instead as shown here. (VIDEO-10893)Room.getStats()
returned statistics for unsubscribed RemoteTracks. (VIDEO-11199)localAudioTrack.stop()
when using noiseCancellation (VIDEO-11047)Once you get the access to the plugin, You can install it from npm with:
npm install <noise_cancellation_plugin>
Once installed, you need to host the contents of ./node_modules/<noise_cancellation_plugin>/dist/
from your web server. We recommend that you add plugin version number to the hosted path to ensure that browser does not use stale version when its updated. You need to pass the path to the hosted files to twilio-video
sdk when creating audio track as shown in the example below. The example below assumes that you have hosted the files at /noise_cancellation_plugin/1.0.0/dist
on your web server.
const { connect, createLocalAudioTrack } = require('twilio-video');
// create a local audio track and have it use
// @twilio/krisp-audio-plugin for noise cancellation processing.
const localAudioTrack = await Video.createLocalAudioTrack({
noiseCancellationOptions: {
vendor: 'krisp',
sdkAssetsPath: '/noise_cancellation_plugin/1.0.0/dist'
}
});
// publish the track to a room
const room = await connect( token, {
tracks: [localAudioTrack]
// ... any other connect options
});
// you can enable/disable noise cancellation at runtime
// using noiseCancellation interface exposed by localAudioTrack
function updateNoiseCancellation(enable: boolean) {
const noiseCancellation = localAudioTrack.noiseCancellation;
if (noiseCancellation) {
enable ? noiseCancellation.enable() : noiseCancellation.disable();
}
}
Large Rooms Pilot
twilio-video.js now allows you to create and join a Large Group Room, which supports a large number of Participants (> 50). This feature is in pilot, and requires that your account be enabled in order to use it. Note that the following API changes apply only for Large Rooms, and not for non-large Group Rooms and Peer-to-Peer Rooms.
switchOffReason
, which describes the reason for it being switched off. The switchedOff
event will also have this reason string as a second argument. (VIDEO-8670, VIDEO-8748)mediaStreamTrack
is set to null
whenever it is switched off. When it is switched on, it is set to a MediaStreamTrack. (VIDEO-8668, VIDEO-8745)switchOffReason
changes for an already switched off audio or video RemoteTrack, the switchedOff
event is raised. (VIDEO-8668, VIDEO-8745)isEnabled
property of the RemoteTrack is deprecated and scheduled for removal. Alternatively, you can determine if a RemoteTrack is enabled by using the following expression. (VIDEO-8742, VIDEO-8750)
const isEnabled = remoteTrack.switchOffReason !== 'disabled-by-publisher';
disabled
and enabled
events of the RemoteTrack are deprecated and scheduled for removal. Alternatively, you can handle the switchedOff
and switchedOn
events as shown below. (VIDEO-8742, VIDEO-8750)
let recentSwitchOffReason = remoteTrack.switchOffReason;
remoteTrack.on('switchedOff', switchOffReason => {
recentSwitchOffReason = switchOffReason;
if (switchOffReason === 'disabled-by-publisher') {
/* The RemoteTrack is disabled. */
}
});
remoteTrack.on('switchedOn', () => {
if (recentSwitchOffReason === 'disabled-by-publisher') {
/* The RemoteTrack is enabled. */
}
recentSwitchOffReason = null;
});
isTrackEnabled
property of the RemoteTrackPublication is deprecated and scheduled for removal. Alternatively, you can determine if a RemoteTrackPublication is enabled by using the following expression. (VIDEO-8743, VIDEO-8751)
const { track } = remoteTrackPublication;
const isTrackEnabled = !(track && track.switchOffReason === 'disabled-by-publisher');
isTrackEnabled
is now only valid for RemoteTracks that are subscribed to, and defaults to true
for unsubscribed
RemoteTracks.trackDisabled
and trackEnabled
events of the RemoteTrack are deprecated and scheduled for removal. Alternatively, you can handle the trackSwitchedOff
and trackSwitchedOn
events as shown below. (VIDEO-8743, VIDEO-8751)
const { track } = remoteTrackPublication;
let recentSwitchOffReason = track ? track.switchOffReason : null;
remoteTrackPublication.on('trackSwitchedOff', (track, switchOffReason) => {
recentSwitchOffReason = switchOffReason;
if (switchOffReason === 'disabled-by-publisher') {
/* The RemoteTrack is disabled. */
}
});
remoteTrackPublication.on('trackSwitchedOn', (track) => {
if (recentSwitchOffReason === 'disabled-by-publisher') {
/* The RemoteTrack is enabled. */
}
recentSwitchOffReason = null;
});
The trackDisabled
and trackEnabled
events are now only fired for subscribed RemoteTracks.connect()
is resolved. The application will now have to listen to the "trackPublished" event on the LocalParticipant. (VIDEO-8817)
const room = await connect('token', {
audio: true,
video: true,
room: 'my-large-room'
});
room.localParticipant.on('trackPublished', publication => {
console.log(`Successfully published ${publication.kind} Track`);
});
Room.getStats()
is broken, and will be fixed in an upcoming release. For now, the Track-level stats returned by this method will not be accurate.This release include the Media Warnings API (Beta) to help surface media related warning events on the SDK whenever the media server is not able to detect media from a published audio or video track.
const room = await connect('token', {
notifyWarnings: [ 'recording-media-lost' ]
// Other connect options
});
Array.from(room.localParticipant.tracks.values()).forEach(publication => {
publication.on('warning', name => {
if (name === 'recording-media-lost') {
console.log(`LocalTrack ${publication.track.name} is not recording media.`);
// Wait a reasonable amount of time to clear the warning.
const timer = setTimeout(() => {
// If the warning is not cleared, you can manually
// reconnect to the room, or show a dialog to the user
}, 5000);
publication.once('warningsCleared', () => {
console.log(`LocalTrack ${publication.track.name} warnings have cleared!`);
clearTimeout(timer);
});
}
});
});
notifyWarnings - An array of warnings to listen to. By default, this array is empty and no warning events will be raised. Possible warning values include:
recording-media-lost
- Raised when the media server has not detected any media on the published track that is being recorded in the past 30 seconds. This usually happens when there are network interruptions or when the track has stopped.The SDK raises warning events when it detects certain conditions. You can implement callbacks on these events to act on them, or to alert the user of an issue. Subsequently, "warningsCleared" event is raised when conditions have returned to normal.
LocalTrackPublication.on('warning', callback(name)) - Raised when the published Track encounters a warning.
LocalTrackPublication.on('warningsCleared', callback()) - Raised when the published Track cleared all warning.
LocalParticipant.on('trackWarning', callback(name, publication)) - Raised when one of the LocalParticipant's published tracks encounters a warning.
LocalParticipant.on('trackWarningsCleared', callback(publication)) - Raised when one of the LocalParticipant's published tracks cleared all warning.
Room.on('trackWarning', callback(name, publication, participant)) - Raised when one of the LocalParticipant's published tracks in the Room encounters a warning.
Room.on('trackWarningsCleared', callback(publication, participant)) - Raised when one of the LocalParticipant's published tracks in the Room cleared all warning.
dimensionsChanged
event was not firing when the track dimensions first became available. (VIDEO-3576)