How to use the twilio-video.createLocalVideoTrack function in twilio-video

To help you get started, we’ve selected a few twilio-video examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / twilio-video / twilio-video-tests.ts View on Github external
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);
    });
  });
github TwilioDevEd / api-snippets / video / getting-started / setup-local-media / setup-local-media.js View on Github external
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);
});
github philnash / mediadevices-camera-selection / video-chat / quickstart / src / index.js View on Github external
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);
    });
github ksocha / twilio-screensharing / client / src / components / App / AppContainer.js View on Github external
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();
github TwilioDevEd / api-snippets / video / rooms / display-camera-preview / display-camera-preview.js View on Github external
const { createLocalVideoTrack } = require('twilio-video');

createLocalVideoTrack().then(track => {
  var localMediaContainer = document.getElementById('local-media-ctr');
  localMediaContainer.appendChild(track.attach());
});
github twilio / video-quickstart-js / examples / remotetracks / src / index.js View on Github external
async function connectToRoom(creds) {
  const videoTrack = await Video.createLocalVideoTrack();
  const room = await Video.connect(creds.token, {
    name: roomName,
    tracks: [generateAudioTrack(), videoTrack]
  });

  return room;
}
github twilio / video-quickstart-js / examples / mediadevices / src / helpers.js View on Github external
function applyVideoInputDeviceSelection(deviceId, video) {
  return Video.createLocalVideoTrack({
    deviceId: deviceId,
    height: 240,
    width: 320
  }).then(function(localTrack) {
    localTrack.attach(video);
  });
}