All Projects → twilio → Twilio Video.js

twilio / Twilio Video.js

Licence: other
Twilio’s Programmable Video JavaScript SDK

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Twilio Video.js

Twilio Video App React
A collaboration application built with the twilio-video.js SDK and React.js
Stars: ✭ 1,233 (+202.21%)
Mutual labels:  twilio, webrtc
Routr
Routr: Next-generation SIP Server
Stars: ✭ 788 (+93.14%)
Mutual labels:  twilio, webrtc
Twilio Video App Android
A collaboration application built with the Twilio Video Android SDK
Stars: ✭ 186 (-54.41%)
Mutual labels:  twilio, webrtc
Audioswitch
An Android audio management library for real-time communication apps.
Stars: ✭ 69 (-83.09%)
Mutual labels:  twilio, webrtc
Twilio Contact Center
A contact center built on Twilio, supporting voice calls, web chat, callback, Facebook Messenger and SMS chat
Stars: ✭ 176 (-56.86%)
Mutual labels:  twilio, webrtc
Fonos
🚀 The open-source alternative to Twilio
Stars: ✭ 3,785 (+827.7%)
Mutual labels:  twilio, webrtc
Twilio Video App Ios
A collaboration application built with the Twilio Video iOS SDK
Stars: ✭ 196 (-51.96%)
Mutual labels:  twilio, webrtc
Eureca.io
eureca.io : a nodejs bidirectional RPC that can use WebSocket, WebRTC or XHR fallback as transport layers
Stars: ✭ 341 (-16.42%)
Mutual labels:  webrtc
Twilio Java
A Java library for communicating with the Twilio REST API and generating TwiML.
Stars: ✭ 371 (-9.07%)
Mutual labels:  twilio
Filepizza
🍕 Peer-to-peer file transfers in your browser
Stars: ✭ 3,622 (+787.75%)
Mutual labels:  webrtc
Ice4j
A Java implementation of the ICE protocol
Stars: ✭ 332 (-18.63%)
Mutual labels:  webrtc
Libdatachannel
C/C++ WebRTC Data Channels and Media Transport standalone library
Stars: ✭ 336 (-17.65%)
Mutual labels:  webrtc
Quickblox Ios Sdk
QuickBlox iOS SDK for messaging and video calling
Stars: ✭ 373 (-8.58%)
Mutual labels:  webrtc
Webrtc.net
WebRTC for C# & C++/CLI
Stars: ✭ 340 (-16.67%)
Mutual labels:  webrtc
Echoplexus
Socket.io powered chat, JavaScript REPL, whiteboard, and WebRTC calls
Stars: ✭ 392 (-3.92%)
Mutual labels:  webrtc
React Native Phone Verification
The best React Native example for phone verification (an alternative to Twitter Digits).
Stars: ✭ 332 (-18.63%)
Mutual labels:  twilio
P
Peer-to-peer networking with browsers
Stars: ✭ 400 (-1.96%)
Mutual labels:  webrtc
Flutter Webrtc Server
A simple WebRTC signaling server for flutter-webrtc.
Stars: ✭ 384 (-5.88%)
Mutual labels:  webrtc
Media Server Go
WebRTC media server for go
Stars: ✭ 362 (-11.27%)
Mutual labels:  webrtc
Gortcd
Fast TURN and STUN server: cross-platform, hot reload, flexible config
Stars: ✭ 358 (-12.25%)
Mutual labels:  webrtc

NEW: Please check out our Best Practices Guide for building video applications with twilio-video.js.

twilio-video.js

NPM CircleCI Windows Build status

For 1.x, go here.

twilio-video.js allows you to add real-time voice and video to your web apps.

We want your feedback! Please feel free to open a [email protected].

Browser Support

Chrome Edge (Chromium) Firefox Safari
Android - -
iOS * - *
Linux - -
macOS ✓ **
Windows ✓ ** -

* Chrome and Firefox for iOS do not have access to WebRTC APIs, unlike Safari for iOS.

** twilio-video.js supports the Chromium-based Edge browser.

Installation

NPM

npm install twilio-video --save

Using this method, you can require twilio-video.js like so:

const Video = require('twilio-video');

TypeScript definitions can now be imported using this method.

import * as Video from 'twilio-video';

function participantDisconnected(participant: Video.RemoteParticipant) {
  console.log('Participant "%s" disconnected', participant.identity);
  document.getElementById(participant.sid).remove();
}

Alternatively, you can import just the definitions you need like so:

import { RemoteParticiant } from 'twilio-video';

function participantDisconnected(participant: RemoteParticipant) {
  console.log('Participant "%s" disconnected', participant.identity);
  document.getElementById(participant.sid).remove();
}

CDN

Releases of twilio-video.js are hosted on a CDN, and you can include these directly in your web app using a <script> tag.

<script src="//media.twiliocdn.com/sdk/js/video/releases/2.13.1/twilio-video.min.js"></script>

Using this method, twilio-video.js will set a browser global:

const Video = Twilio.Video;

Usage

The following is a simple example for connecting to a Room. For more information, refer to the API Docs.

const Video = require('twilio-video');

Video.connect('$TOKEN', { name: 'room-name' }).then(room => {
  console.log('Connected to Room "%s"', room.name);

  room.participants.forEach(participantConnected);
  room.on('participantConnected', participantConnected);

  room.on('participantDisconnected', participantDisconnected);
  room.once('disconnected', error => room.participants.forEach(participantDisconnected));
});

function participantConnected(participant) {
  console.log('Participant "%s" connected', participant.identity);

  const div = document.createElement('div');
  div.id = participant.sid;
  div.innerText = participant.identity;

  participant.on('trackSubscribed', track => trackSubscribed(div, track));
  participant.on('trackUnsubscribed', trackUnsubscribed);

  participant.tracks.forEach(publication => {
    if (publication.isSubscribed) {
      trackSubscribed(div, publication.track);
    }
  });

  document.body.appendChild(div);
}

function participantDisconnected(participant) {
  console.log('Participant "%s" disconnected', participant.identity);
  document.getElementById(participant.sid).remove();
}

function trackSubscribed(div, track) {
  div.appendChild(track.attach());
}

function trackUnsubscribed(track) {
  track.detach().forEach(element => element.remove());
}

Changelog

See CHANGELOG.md.

Content Security Policy (CSP)

Want to enable CSP in a way that's compatible with twilio-video.js? Use the following policy directives:

connect-src wss://global.vss.twilio.com wss://sdkgw.us1.twilio.com
media-src mediastream:

If you're loading twilio-video.js from media.twiliocdn.com, you should also include the following script-src directive:

script-src https://media.twiliocdn.com

Keep in mind, you may need to merge these policy directives with your own if you're using other services.

License

See LICENSE.md.

Building

Fork and clone the repository. Then, install dependencies with

npm install

Then run the build script:

npm run build

The builds and docs will be placed in the dist/ directory.

Testing

Run unit tests with

npm run test:unit

Run integration tests with

ACCOUNT_SID=<Your account sid> \
API_KEY_SID=<Your api key sid> \
API_KEY_SECRET=<Your api key secret> \
BROWSER=<Browser you'd like to use> \
npm run test:integration

You can add these optional variables to control the integration test execution :

  • Topology : Decides which type of rooms to test against.
  • Debug : To get better source mapping, and the browser does not close after tests are run which allows you to easily step through code to debug.
  • Test Files : Allows you to limit the test to just one file.
TOPOLOGY=<peer-to-peer|group>
DEBUG=1
TEST_FILES=<path_ to_the_file>

Tips

  • Use Pre-commit hook: We have some useful pre-commit hook that would help identify common mistakes before commit. Use them by executing
ln -s ../../pre-commit.sh .git/hooks/pre-commit

Contributing

Bug fixes welcome! If you're not familiar with the GitHub pull request/contribution process, this is a nice tutorial.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].