npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bandyer/web-core-av

v1.20.1

Published

Bandyer web core av module

Downloads

141

Readme

Bandyer Web Core AV

This module provide the Core Audio Video utilities for Bandyer Video using WebRTC.

Stream

The stream object implements the stream (webcam or screen) acquired by the device of the web client.

Methods:

  • initialize(): initialize the Stream object
  • initStream(streamConfig, attributes): given a stream config and attributes it init the stream in the browser.
  • toggleAudioTrack()
  • toggleVideoTrack()
  • closeStream()

You will not directly interact with the Stream object. We encourage to use the publisher object.

API doc here: Stream

Publisher

The publisher object handles the Webcam o Screen Media Resources of the user.

Get local webcam

.initLocalWebcam(options: GetUserMediaOptions)

To request access to the client's webcam you should use the initLocalWebcam method with his relative options.

Example:

import {BaseUser, Publisher} from '@bandyer/web-core-av';
// Request client's local webcam access;
const baseUser = BaseUser.initialize({userAlias: 'your_user_alias'});
await Publisher.initialize(baseUser).initLocalWebCam({audio:true, video:true});

Get local screen

.initLocalScreen(audio, extensionId?)

To request access to the client's screen you should use the initLocalScreen function. You must specify if you want the audio track or not. The parameter extensionsId is requierd only for GoogleChrome browser.

Example:

import {Publisher} from '@bandyer/web-core-av';
// Request client's screen webcam access;
const baseUser = BaseUser.initialize({userAlias: 'your_user_alias'});
await Publisher.initialize(baseUser).initLocalScreen(true, 'extensiond_id');

API doc here: Publisher

Room

Before you can connect to a Room, you need a Token. In order to get a Token, you need to interact with the BandyerCommunicationCenter.

### Initialize

import { Room } from '@bandyer/web-core-av';
var myRoom = Room.initialize(token, recordOption)

You can specify if the room should be recorded or not. The initialize method returns a Room object. Note that calling the method does not connect to a Room; it creates a JS object which represents a Room.

Connect to a room

import { Room } from '@bandyer/web-core-av';
try {
	var myRoom = Room.initialize(token);
	await myRoom.connectRoom();
} catch (err) {
	console.log('Room err:', err);
}

The connectRoom method returns the Room object if the connection was successfull. Otherwise, it throws an error.

Disconnect from a room

myRoom.disconnectRoom();

To disconnect from a room, call the disconnectRoom method.

Publish stream

Once you have connect to a Room, you can publish the stream of a Publisher. First of all, you must initialize a webcam or screen Stream of the Publisher.

// first of all, connect to a room
var myRoom = Room.initialize(token);
await myRoom.connectRoom();

// init client's webcam

var myPub = await Publisher.initialize(baseUser)
await myPub.initLocalWebCam({audio:true, video:true});
// publish the Publisher localwebcam
myRoom.publishStream(myPub.localWebcam)

Unpublish stream

You can stop Publisher from streaming a specific Stream to the room by calling the unpublishStream() method of the Room object:

// unpublish the Publisher localwebcam
myRoom.unpublishStream(myPub.localWebcam)

Room events

room-connected

The room object emit the room-connected event when you successfully connect to a Room. A common use case is to subscribe to streams currently published in the room:


var myRoom = Room.initialize(token);
await myRoom.connectRoom();
myRoom.on('room-connected', function(room) {
	// room.streams contains the streams currently published in the room
	const { streams } = roomEvent.streams;
        for (const index in streams) {
            if ({}.hasOwnProperty.call(streams, index)) {
    			const stream = streams[index];
				myRoom.subscribeStream(stream, {audio: true, video: true} );
        	}
    	}
})
room-disconnected

Emitted when the user has been already disconnected.


var myRoom = Room.initialize(token);
await myRoom.connectRoom();
myRoom.on('room-disconnected', function(room) {
	
})
room-error

Emitted when it hasn't been possible a successfully connection to the room.


var myRoom = Room.initialize(token);
await myRoom.connectRoom();
myRoom.on('room-error', function(room) {
	
})

Full doc here: Room