Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
width: null
}
}
}
}
});
await Video.connect('$TOKEN', {
networkQuality: {
local: 3,
remote: 1
}
});
// Create local video track from default input
localVideoTrack = await Video.createLocalVideoTrack({ name: 'camera' });
// Create local audio track from default input
localAudioTrack = await Video.createLocalAudioTrack({ name: 'microphone' });
// Publish audio track
room.localParticipant.publishTrack(localAudioTrack);
// Subscribe to remote participant tracks
room.participants.forEach(participantConnected);
// Set up listeners
room.on('participantConnected', participantConnected);
room.on('participantDisconnected', participantDisconnected);
room.once('disconnected', (room: Video.Room, error: Video.TwilioError) => {
room.participants.forEach(participantDisconnected);
room.localParticipant.tracks.forEach((publication: Video.LocalTrackPublication) => {
publication.unpublish();
if (publication.track.kind !== 'data') trackUnsubscribed(publication.track);
});
});
}
const {
createLocalTracks,
createLocalAudioTrack,
createLocalVideoTrack
} = require('twilio-video');
var localTracks;
// Create default local audio and video tracks
createLocalTracks().then(localTracks => {
console.log('Got default audio and video tracks:', localTracks);
});
// Create default local track of a particular kind
createLocalAudioTrack().then(audioTrack => {
console.log('Got default local audio track:', audioTrack);
});
createLocalVideoTrack().then(videoTrack => {
console.log('Got default local video track:', videoTrack);
});
function applyAudioInputDeviceSelection(deviceId, audio) {
return Video.createLocalAudioTrack({
deviceId: deviceId
}).then(function(localTrack) {
localTrack.attach(audio);
});
}
joinRoom = async () => {
const { roomName } = this.state;
this.setState({ isJoining: true });
try {
const token = await this.getToken();
const localVideoTrack = await TwilioVideo.createLocalVideoTrack();
this.setState({ localVideoTrack });
const localAudioTrack = await TwilioVideo.createLocalAudioTrack();
this.setState({ localAudioTrack });
const videoRoom = await TwilioVideo.connect(
token,
{
name: roomName,
tracks: [localVideoTrack, localAudioTrack],
insights: false
}
);
videoRoom.on("disconnected", () => {
this.stopVideoTrack();
this.stopAudioTrack();
this.stopScreenTrack();