How to use the twilio-video.createLocalAudioTrack 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
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
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 twilio / video-quickstart-js / examples / mediadevices / src / helpers.js View on Github external
function applyAudioInputDeviceSelection(deviceId, audio) {
  return Video.createLocalAudioTrack({
    deviceId: deviceId
  }).then(function(localTrack) {
    localTrack.attach(audio);
  });
}
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();