How to use the twilio-video.connect 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 twilio / video-quickstart-js / quickstart / src / index.js View on Github external
return;
    }

    log("Joining room '" + roomName + "'...");
    var connectOptions = {
      name: roomName,
      logLevel: 'debug'
    };

    if (previewTracks) {
      connectOptions.tracks = previewTracks;
    }

    // Join the Room with the token from the server and the
    // LocalParticipant's Tracks.
    Video.connect(data.token, connectOptions).then(roomJoined, function(error) {
      log('Could not connect to Twilio: ' + error.message);
    });
  };
github philnash / screen-capture / video-chat / src / index.js View on Github external
return;
      }

      log("Joining room '" + roomName + "'...");
      var connectOptions = {
        name: roomName,
        logLevel: 'debug'
      };

      if (previewTracks) {
        connectOptions.tracks = previewTracks;
      }

      // Join the Room with the token from the server and the
      // LocalParticipant's Tracks.
      Video.connect(data.token, connectOptions).then(roomJoined, function(
        error
      ) {
        log('Could not connect to Twilio: ' + error.message);
      });
    };
github philnash / mediadevices-camera-selection / video-chat / quickstart / src / index.js View on Github external
return;
    }

    log("Joining room '" + roomName + "'...");
    var connectOptions = {
      name: roomName,
      logLevel: 'debug'
    };

    if (previewTracks) {
      connectOptions.tracks = previewTracks;
    }

    // Join the Room with the token from the server and the
    // LocalParticipant's Tracks.
    Video.connect(data.token, connectOptions).then(roomJoined, function(error) {
      log('Could not connect to Twilio: ' + error.message);
    });
  };
github twilio / video-quickstart-js / examples / codecpreferences / src / index.js View on Github external
(async function() {
  // Load the code snippet.
  const snippet = await getSnippet('./helpers.js');
  const pre = document.querySelector('pre.language-javascript');
  pre.innerHTML = Prism.highlight(snippet, Prism.languages.javascript);

  // Set listener to the connect or disconnect button.
  connectOrDisconnect.onclick = connectToOrDisconnectFromRoom;

  // Get the credentials to connect to the Room.
  const creds = await getRoomCredentials();

  // Connect to a random Room with no media. This Participant will
  // display the media of the second Participant that will enter
  // the Room with preferred codecs.
  const someRoom = await Video.connect(creds.token, { tracks: [] });

  // Disconnect from the Room on page unload.
  window.onbeforeunload = function() {
    if (room) {
      room.disconnect();
      room = null;
    }
    someRoom.disconnect();
  };

  // Set the name of the Room to which the Participant that shares
  // media should join.
  roomName = someRoom.name;

  // Attach the newly subscribed Track to the DOM.
  someRoom.on('trackSubscribed', attachTrack.bind(
github twilio / twilio-video.js / test / framework / twilio-video-meteor / client / main.js View on Github external
Template.body.helpers({
  error() {
    return Template.instance().error.get();
  },

  room() {
    return Template.instance().room.get();
  },

  disconnected() {
    return Template.instance().disconnected.get();
  }
});

connect(token).then(_room => {
  room.set(_room);
  _room.once('disconnected', disconnected.set(true));
  _room.disconnect();
}, _error => {
  error.set(_error);
});
github twilio / twilio-video.js / test / framework / twilio-video-react / src / App.js View on Github external
constructor(props) {
    super(props);

    this.state = {};

    connect(this.props.token).then(room => {
      this.setState({ room });
      room.once('disconnected', () => this.forceUpdate());
      room.disconnect();
    }, error => {
      this.setState({ error });
    });
  }
github TwilioDevEd / api-snippets / video / rooms / specify-constraints / specify-constraints.js View on Github external
}).then(localTracks => {
  return connect('$TOKEN', {
    name: 'my-room-name',
    tracks: localTracks
  });
}).then(room => {
  console.log('Connected to Room:', room.name);
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 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();
        this.stopAudioTrack();
        this.stopScreenTrack();

        this.setState({
          videoRoom: null
        });
github twilio / video-quickstart-js / examples / dominantspeaker / src / index.js View on Github external
async function connectToRoom(creds) {
  const room = await Video.connect( creds.token, {
    name: roomName
  });

  return room;
}