Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow settings to be passed in

  • Loading branch information...
commit 9e9a14288521e7206efc8f3f5c9a7cf5c8bf4084 1 parent b58aee0
Andrew Weeks authored
Showing with 26 additions and 4 deletions.
  1. +17 −2 README.md
  2. +1 −1  config/vidStreamer-sample.json
  3. +8 −1 index.js
19 README.md
View
@@ -25,6 +25,21 @@ app.get("/videos/", vidStreamer);
app.listen(3000);
```
+If you want to pass in the settings instead via your app, try this (thanks to [Will Laurance](https://github.com/meloncholy/vid-streamer/issues/3)). Settings given will be merged with the defaults (see below), so you don't need to supply them all.
+
+```javascript
+var http = require("http");
+var vidStreamer = require("vid-streamer");
+
+var newSettings = {
+ rootPath: "download-clips/",
+ forceDownload: true
+}
+
+var app = http.createServer(vidStreamer.settings(newSettings));
+app.listen(3000);
+```
+
Installation
------------
@@ -51,7 +66,7 @@ Standalone example
"random": false,
"rootFolder": "/path/to/videos/",
"rootPath": "videos/",
- "server": "VidStreamer.js/0.1"
+ "server": "VidStreamer.js/0.1.3"
}
```
@@ -64,7 +79,7 @@ Example for Express. (Note that rootPath should be relative to the root URL of y
"random": false,
"rootFolder": "/path/to/express/public/",
"rootPath": "",
- "server": "VidStreamer.js/0.1"
+ "server": "VidStreamer.js/0.1.3"
}
```
2  config/vidStreamer-sample.json
View
@@ -4,5 +4,5 @@
"random": false,
"rootFolder": "/path/to/videos/",
"rootPath": "videos/",
- "server": "VidStreamer.js/0.1.2"
+ "server": "VidStreamer.js/0.1.3"
}
9 index.js
View
@@ -58,7 +58,9 @@ var mimeTypes = {
".vcf": "text/x-vcard",
".vrml": "x-world/x-vrml",
".zip": "application/zip",
- ".webm": "video/webm"
+ ".webm": "video/webm",
+ ".m3u8": "application/x-mpegurl",
+ ".ts": "video/mp2t"
};
var vidStreamer = function (req, res) {
@@ -142,6 +144,11 @@ var vidStreamer = function (req, res) {
return true;
};
+vidStreamer.settings = function (s) {
+ for (var prop in s) { settings[prop] = s[prop]; }
+ return vidStreamer;
+};
+
var randomFile = function (info) {
var fileCode = 0;
var fileParts;
Please sign in to comment.
Something went wrong with that request. Please try again.