0.1.54 • Published 5 years ago

janus-room v0.1.54

Weekly downloads
10
License
MIT
Repository
-
Last release
5 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.54

5 years ago

0.1.53

5 years ago

0.1.52

5 years ago

0.1.51

5 years ago

0.1.50

5 years ago

0.1.49

5 years ago

0.1.48

5 years ago

0.1.47

5 years ago

0.1.46

5 years ago

0.1.45

5 years ago

0.1.44

5 years ago

0.1.43

5 years ago

0.1.42

5 years ago

0.1.41

5 years ago

0.1.40

5 years ago

0.1.39

5 years ago

0.1.38

5 years ago

0.1.37

5 years ago

0.1.36

5 years ago

0.1.35

5 years ago

0.1.34

5 years ago

0.1.33

5 years ago

0.1.32

5 years ago

0.1.31

5 years ago

0.1.30

5 years ago

0.1.29

5 years ago

0.1.28

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.21-t

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.7

6 years ago

0.0.7

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago