VidStreamer.js: A simple streamer for Flash and other videos (and other files too). Supports HTTP pseudostreaming and works with JW Player's bitrate switching.
To make a standalone video streamer, try something like this
var http = ;var vidStreamer = ;var app = http;app;console;
And here's an example of including it in an Express app
var app = ;var vidStreamer = ;app;app;
If you want to pass in the settings instead via your app, try this (thanks to Will Laurance). Settings given will be merged with the defaults (see below), so you don't need to supply them all.
var http = ;var vidStreamer = ;var newSettings =rootPath: "download-clips/"forceDownload: truevar app = http;app;
You should be able to get it via
npm install vid-streamer, or otherwise through Git of course.
There are a few things to twiddle in
/config/vidStreamer.json. (Please rename
- mode - Not actually used right now. :)
- forceDownload - Tell the browser to show a save file dialog.
- random - Show a random file instead of the one named (see below).
- rootFolder - The root folder from which files are returned. Accessing subfolders is possible by putting them in the path.
- rootPath - The path assumed to match up with the root folder.
- server - Server string returned in the header.
- throttle - Allows you to throttle (limit) server bandwidth (bytes/second), cool for dev where
"mode": "development""forceDownload": false"random": false"rootFolder": "/path/to/videos/""rootPath": "videos/""server": "VidStreamer.js/0.1.4"
Example for Express. (Note that rootPath should be relative to the root URL of your Express app.)
"mode": "development""forceDownload": false"random": false"rootFolder": "/path/to/express/public/""rootPath": """server": "VidStreamer.js/0.1.4"
Serving random files
You can use VidStreamer to serve up random files instead of the actual file requested. This can be useful if you're demoing an app that's supposed to have hundreds of videos but you don't want to go to the trouble of making them all.
- Which file to return is calculated from the requested file name, so the same one will be returned each time for the same name. This is useful if you want to switch between video bitrates for example.
- The file returned will be of the same type (same extension) as the requested file.
- The file returned will be from the same folder as the requested file.
Copyright © 2012 Andrew Weeks http://meloncholy.com
VidStreamer.js is licensed under the MIT licence.