Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
opentok-angular
Advanced tools
Angular Module to make working with OpenTok more Angularish.
It only works with the OpenTok API for WebRTC.
This Angular Module was originally created to power opentok-meet (github). It's a pretty good example of how to use it.
npm install opentok-angular
This component can be installed using bower. Simply run bower install opentok-angular
.
clone this repo and include the opentok-angular.min.js
file in your page.
To run the demo.html file.
npm install
If you want to contribute to this project you will need to know how to build and test.
npm install
npm test
Easy as that.
This component requires that you include the OpenTok Library v2.2+, AngularJS v1.2.2+. Optionally it also requires the opentok-layout-js component v0.0.6+ and jQuery 1.9+ for automatic layout and animation.
angular.module('MyApp', ['opentok'])
.controller('MyCtrl', ['$scope', 'OTSession', 'apiKey', 'sessionId', 'token', function($scope, OTSession, apiKey, sessionId, token) {
OTSession.init(apiKey, sessionId, token, function(err, session) {
// Here you can do things to the OpenTok session
// The err is bubbled up from session.connect
});
$scope.streams = OTSession.streams;
}]).value({
apiKey: 'REPLACE_WITH_YOUR_APIKEY',
sessionId: 'REPLACE_WITH_YOUR_SESSION_ID',
token: 'REPLACE_WITH_YOUR_TOKEN'
});
The publisher directive uses the power of Angular directives to allow you to define an OpenTok publisher directly in your DOM. This publisher creates a standalone publisher using TB.initPublisher and if you pass a reference to a session then session.publish will be called when the publisher is ready. Alternatively you can pass a reference to this publisher to the ot-session directive and session.publish(publisher) will be called when the session connects.
This directive requires the OpenTok JavaScript WebRTC library to be included in your page. For more details see the opentok documentation.
"otPublisherError"
- This event is emitted on the scope if there is an error creating or publishing this publisher.Include the OpenTok TB.min.js file and the opentok-angular.js file in your HTML.
angular.module('myModule', ['opentok']);
<ot-publisher props="{name: 'Adam'}"></ot-publisher>
The subscriber directive uses the power of Angular directives to allow you to define an OpenTok subscriber directly in your DOM. You will likely want to iterate over some kind of collection of streams and create subscriber objects for those streams. You can either maintain that list of streams yourself or you can use the streams provided by the ot-session directive.
This directive requires the OpenTok JavaScript WebRTC library to be included in your page. For more details see the opentok documentation.
"otSubscriberError"
- This event is emitted on the scope if there is an error subscribing.angular.module('myModule', ['opentok']);
<ot-subscriber ng-repeat="stream in streams"
stream="stream"
props="{style: {nameDisplayMode: 'off'}}">
</ot-subscriber>
This directive handles some nice layout logic for you to layout your publishers and subscribers. What it does is intelligently size a bunch of video elements to fit within a specified space. You can see a demo here.
You can put Publishers and/or Subscribers into it and it will basically size the widgets to fit within the container and minimise whitespace.
This directive uses the opentok-layout-js component.
layout()
method of opentok-layout-js. The Publisher and Subscriber directives automatically trigger these events when they are loaded, it is also triggered on window resize. But if there are other times when you want to redraw the layout container you can trigger it manually.'otLayoutComplete'
is emitted on the scope.angular.module('myModule', ['opentok']);
<ot-layout props="{animate:true}">
<ot-subscriber ng-repeat="stream in streams"
stream="stream"
session="session"
props="{style: {nameDisplayMode: 'off'}}">
</ot-subscriber>
</ot-layout>
These directives are meant to all be used together, an example of them all being used can be found here. You will need to put in your own sessionId and token to get it to work. A more fully-functional demo can be found at: opentok-meet.
FAQs
Angular module for OpenTok
The npm package opentok-angular receives a total of 27 weekly downloads. As such, opentok-angular popularity was classified as not popular.
We found that opentok-angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.