Code Monkey home page Code Monkey logo

janus-room's Introduction

npm version

Janus Room

A Janus client library that provides simple interface to create a minimal-complete conference video room. This is adopted from Janus demo example code but it's JQuery-less and React/Vue friendly.

Install

$ npm install janus-room

Basic usage

import Room from 'janus-room';

...

var options = {
  server: server, // required

  // Event handlers
  onLocalJoin: onLocalJoin,
  onRemoteJoin: onRemoteJoin,
  onRemoteUnjoin: onRemoteUnjoin,
  onMessage: onMessage,
  onError: onError,
}

var room = new Room(options);
room.init()
.then(function(){
  room.register({
    room: roomId,
    username: username
  });
})
.catch(function(err){
  alert(err);
});

Methods

  • room.init() - Initialize the session.

  • room.register({room: roomId, username: username}) - Join to the room as username.

  • room.sendMessage(data) - Send message throught Janus's DataChannel (activated by default).

  • room.attachStream(element, streamIndex) - Attach a remote stream to a <video> element. Local stream is on 0.

  • room.shareScreen() - Share screen.

  • room.stopShareScreen() - Stop share screen and switch back to webcam.

  • room.createRoom({room:1337}) - Create new room.

  • room.removeRoom() - Remove current room.

  • room.isShareScreenStream(streamIndex) - Detect whether the stream is a sharescreen. Local stream is on 0.

  • room.getStream(streamIndex) - Get stream instance by stream index.

  • room.getStreamBitrate(streamIndex) - Get stream last bitrate by stream index.

  • room.toggleMuteAudio() - Toggle local mic.

  • room.toggleMuteVideo() - Toggle local video stream.

  • room.toggleVideo() - Toggle local video stream.

Please note that toggleMute* only mute the stream, not stop it. Use togggleVideo() instead to stop the video stream.

Events (passed as params)

  • onLocalJoin(() => { ...
  • onRemoteJoin((streamIndex, username, feedId) => { ...
  • onRemoteUnjoin((streamIndex) => { ...
  • onMessage((data) => { ...
  • onVolumeMeterUpdate((streamIndex, volumeLevel) => { ...
  • onError((err) => { ...
  • onWarning((msg) => { ...

Working example

Adjust the Janus gateway URL in example.js, then,

  • npm install
  • npm run build
  • Open example.html on your web browser.

Warning

janus-room is still in heavy development and will makes many breaking API changes.


tarsier

janus-room's People

Contributors

dependabot[bot] avatar drayanaindra avatar herpiko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.