How to use the twilio-video.createLocalTracks 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 TwilioDevEd / api-snippets / video / getting-started / setup-local-media / setup-local-media.js View on Github external
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);
});
github TwilioDevEd / api-snippets / video / rooms / specify-constraints / specify-constraints.js View on Github external
const { connect, createLocalTracks } = require('twilio-video');

// Option 1
createLocalTracks({
  audio: true,
  video: { width: 640 }
}).then(localTracks => {
  return connect('$TOKEN', {
    name: 'my-room-name',
    tracks: localTracks
  });
}).then(room => {
  console.log('Connected to Room:', room.name);
});

// Option 2
connect('$TOKEN', {
  audio: true,
  name: 'my-room-name',
  video: { width: 640 }
github philnash / mediadevices-camera-selection / video-chat / quickstart / src / index.js View on Github external
document.getElementById('button-preview').onclick = function() {
  var localTracksPromise = previewTracks
    ? Promise.resolve(previewTracks)
    : Video.createLocalTracks();

  localTracksPromise.then(
    function(tracks) {
      window.previewTracks = previewTracks = tracks;
      var previewContainer = document.getElementById('local-media');
      if (!previewContainer.querySelector('video')) {
        attachTracks(tracks, previewContainer);
      }
    },
    function(error) {
      console.error('Unable to access local media', error);
      log('Unable to access Camera and Microphone');
    }
  );
};
github philnash / screen-capture / video-chat / src / index.js View on Github external
document.getElementById('button-preview').onclick = function() {
  var localTracksPromise = previewTracks
    ? Promise.resolve(previewTracks)
    : Video.createLocalTracks();

  localTracksPromise.then(
    function(tracks) {
      window.previewTracks = previewTracks = tracks;
      var previewContainer = document.getElementById('local-media');
      if (!previewContainer.querySelector('video')) {
        attachTracks(tracks, previewContainer);
      }
    },
    function(error) {
      console.error('Unable to access local media', error);
      log('Unable to access Camera and Microphone');
    }
  );
};
github twilio / video-quickstart-js / quickstart / src / index.js View on Github external
document.getElementById('button-preview').onclick = function() {
  var localTracksPromise = previewTracks
    ? Promise.resolve(previewTracks)
    : Video.createLocalTracks();

  localTracksPromise.then(function(tracks) {
    window.previewTracks = previewTracks = tracks;
    var previewContainer = document.getElementById('local-media');
    if (!previewContainer.querySelector('video')) {
      attachTracks(tracks, previewContainer);
    }
  }, function(error) {
    console.error('Unable to access local media', error);
    log('Unable to access Camera and Microphone');
  });
};
github raghav-grover / react-twilio / src / components / TwilioConnectionManager.js View on Github external
connectToTwilio(token, roomName) {

        this.token = token;
        //throw new Error();
        Video.createLocalTracks().then((localTrack) => {
            this.localTrack = localTrack;
            Video
                .connect(token, { name: roomName, track: localTrack })
                .then(room => {
                    this.setState((prevState) => { return { ...prevState, currentRoom: room } })
                    this.iterateLocalParticipantTracks(room.localParticipant);
                    room.participants.forEach(this.participantConnected);
                    room.on('participantConnected', this.participantConnected);
                    room.on('participantDisconnected', this.participantDisconnected);
                    room.once('disconnected', error => room.participants.forEach(this.participantDisconnected));
                }, (err) => {
                    this.showTwilioError();
                });
        }, () => {
            this.showTwilioError();
        });
github twilio / draw-with-twilio / src / index.js View on Github external
async function setupLocalAudioAndVideoTracks(video) {
  const audioAndVideoTrack = await createLocalTracks();
  audioAndVideoTrack.forEach(track => track.attach(video));
  return audioAndVideoTrack;
}