0.1.75 • Published 2 years ago

new-janus-room v0.1.75

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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

0.1.75

2 years ago

0.1.73

2 years ago

0.1.72

2 years ago

0.1.71

2 years ago

0.1.7

2 years ago

0.1.62

2 years ago

0.1.6-1.6

2 years ago

0.1.6-1.5

2 years ago

0.1.6-1.4

2 years ago

0.1.6-1.3

2 years ago

0.1.6-1.2

2 years ago

0.1.6-1.1

2 years ago

0.1.61

2 years ago

0.1.6-0.3

2 years ago

0.1.6-0.2

2 years ago

0.1.6-0.1

2 years ago

0.1.60

2 years ago

0.1.5-9.6

2 years ago

0.1.5-9.5

2 years ago

0.1.5-9.4

2 years ago

0.1.5-9.3

2 years ago

0.1.5-9.2

2 years ago

0.1.5-9.1

2 years ago

0.1.59

2 years ago

0.1.5-8.5

2 years ago

0.1.5-8.3

2 years ago

0.1.5-8.2

2 years ago

0.1.5-8.1

2 years ago

0.1.58

2 years ago

0.1.5-7.2

2 years ago

0.1.5-7.1

2 years ago

0.1.57

2 years ago

0.1.5-6.5

2 years ago

0.1.5-6.4

2 years ago

0.1.5-6.3

2 years ago

0.1.5-6.2

2 years ago

0.1.5-6.1

2 years ago

0.1.56

2 years ago

0.1.55

2 years ago

0.1.54

2 years ago