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

webcamstreaming-js

v1.0.2

Published

Easily implement videostreaming in your node-applications using server-side rendering and websockets

Downloads

4

Readme

Easily insert video-streaming capabilities into your Node applications

** This library lets you implement simple client to client live video-streaming in only five steps

  1. Instantiate your node application and an http server (make sure to npm install http)
var app = require('express')();
var http = require('http').Server(app);
  1. Require the nodevideostreaming library
  var lib = require("webcamstreaming-js");
  1. Create a new instance of the library by passing your app and the server as arguments
  var lib = new lib(app,http);
  1. Serve your html files through your app using the sendFile function on the lib, not the native sendFile function
app.get('/',function(req,res){
	lib.sendFile(__dirname + "/test-html.html",res);
})
  1. Your html file now has two helper functions defined: insertStreamer and insertClient. Both take two arguments: the first argument is a string representing the id of a div in your html, the second is a string representing the name you want to give to this users stream. Having named streams lets you allow users to sign into other user's streams (e.g. "rooms functionality")
//API:
//insertStream(divName,streamName)
//insertClient(divName,streamName)	

insertStreamer opens the user's webcam and begins streaming video. It also attaches a video to the div whose id you passed in, so that the user can see their own cameras output

Example: to start streaming from a webcam on a stream named "myStream", your html could look like this

<html>
	<head>
	</head>
	<body>
		<div id ="Test"></div>
		<script>
			insertStreamer("Test","myStream");
		</script>
	</body>
</html>

~~~html
This will only work if you've served your html file using the librarys sendFile function

Then, to receive the streamed video, you run insertClient from the html. insertClient will receive any video that is streaming through your server under the specified streamname. It will insert a video of the feed into the div you specified in the first argument

Example: To receive streaming video, you could do this: 

~~~html
<html>
	<head>
	</head>
	<body>
		<div id ="Test"></div>
		<script>
			insertClient("Test","myStream");
		</script>
	</body>
</html>

You can use insertStream and insertClient in combination with user input to set up an app that allows users to stream to different rooms.

Note: This is a naive webstreaming solution using getusermedia (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia). For large projects use webrtc (https://webrtc.org/)