Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
low: {
height: 500,
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);
});
});
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 updateVideoDevice(event) {
const select = event.target;
const localParticipant = room.localParticipant;
if (select.value !== '') {
Video.createLocalVideoTrack({
deviceId: { exact: select.value }
}).then(function(localVideoTrack) {
const tracks = Array.from(localParticipant.videoTracks.values()).map(
function(trackPublication) {
return trackPublication.track;
}
);
localParticipant.unpublishTracks(tracks);
log(localParticipant.identity + ' removed track: ' + tracks[0].kind);
detachTracks(tracks);
localParticipant.publishTrack(localVideoTrack);
log(localParticipant.identity + ' added track: ' + localVideoTrack.kind);
const previewContainer = document.getElementById('local-media');
attachTracks([localVideoTrack], previewContainer);
});
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();
const { createLocalVideoTrack } = require('twilio-video');
createLocalVideoTrack().then(track => {
var localMediaContainer = document.getElementById('local-media-ctr');
localMediaContainer.appendChild(track.attach());
});
async function connectToRoom(creds) {
const videoTrack = await Video.createLocalVideoTrack();
const room = await Video.connect(creds.token, {
name: roomName,
tracks: [generateAudioTrack(), videoTrack]
});
return room;
}
function applyVideoInputDeviceSelection(deviceId, video) {
return Video.createLocalVideoTrack({
deviceId: deviceId,
height: 240,
width: 320
}).then(function(localTrack) {
localTrack.attach(video);
});
}