Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: maddenpj/node-streamer
base: 49f1ba698b
...
head fork: maddenpj/node-streamer
compare: 8e81a96ae0
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
5 public/index_client.js
View
@@ -1,5 +0,0 @@
-$(function() {
-
-var socket = io.connect();
-
-});
37 public/room_client.js
View
@@ -2,6 +2,43 @@ $(function() {
var socket = io.connect();
+var current = 0;
+var chunk = 2048;
+var file = '';
+
+function doSlice() {
+ var reader = new FileReader();
+
+ var stop = current + chunk - 1;
+ if(stop>(file.size-1)) stop = file.size-1;
+ var corrected_length = (stop-current) +1;
+
+ var blob = file.slice(current, current+corrected_length);
+
+ reader.onloadend = function (event) {
+ socket.emit('file-upload', window.btoa(event.target.result));
+ };
+ reader.readAsBinaryString(blob);
+ console.log('sent: ' + current + ' / ' + file.size);
+
+ current += chunk;
+
+ if(current >= file.size) {
+ console.log('Completed');
+ }
+ else {
+ setTimeout(doSlice, 250);
+ }
+}
+
+$('#file-submit').click(function () {
+ var fileList = document.getElementById('file-input');
+ file = fileList.files[0];
+ doSlice();
+});
+
+
+
var video = document.getElementsByTagName('video')[0];
socket.on('timer', function (data) {
21 server.js
View
@@ -4,9 +4,12 @@ var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
var uplawder = require('./uplawder.js');
+var atob = require('atob');
server.listen(8080); // start listening on 8080
+var debugf = require('fs').createWriteStream('vid.webm');
+
rooms = [];
roomID = 1;
@@ -24,8 +27,10 @@ app.get('/', function (request, response) {
});
app.get('/getroom', function(req, res) {
- rooms.push(roomID);
+ var id = roomID;
roomID++;
+ rooms.push(id);
+ res.redirect('/room/'+id);
});
app.get('/room/:id',function (req,res) {
@@ -33,10 +38,14 @@ app.get('/room/:id',function (req,res) {
res.render('room', { roomName: req.params.id});
});
+app.post('/room/:id', function (req,res) {
+ console.log('Gotcha');
+});
+
var DaStream='';
var DaData = new Buffer(0);
-app.post('/upload', function (req, res) {
+app.post('/upload/:id', function (req, res) {
console.log('Uplawding');
//res.end('Uploading');
@@ -51,7 +60,7 @@ app.post('/upload', function (req, res) {
});
app.get('/stream/:id', function(req,res) {
- var total = DaData.length;
+ /*var total = DaData.length;
if (req.headers['range']) {
var range = req.headers.range;
var parts = range.replace(/bytes=/, "").split("-");
@@ -72,6 +81,7 @@ app.get('/stream/:id', function(req,res) {
res.writeHead(200, { 'Content-Length': total, 'Content-Type': DaStream.mime });
res.end(DaData);
}
+ */
});
function Client(socket)
@@ -111,6 +121,11 @@ io.sockets.on('connection', function (socket) {
paused = true;
});
+ socket.on('file-upload', function (data) {
+ var dbuf = new Buffer(atob(data));
+ debugf.write(dbuf);
+ });
+
socket.on('play', function () {
for(var i = 0; i < clients.length; i++) {
clients[i].socket.emit('play',currentTimer);
9 templates/room.jade
View
@@ -3,20 +3,21 @@ html
head
script(src='/socket.io/socket.io.js')
script(src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js')
+ script
+ var RoomID = #{roomName}
script(src='/room_client.js')
body
h2 Room #{roomName}
#uploader
- form(action="/upload", method="post", enctype="multipart/form-data")
- input(type="file", name="video")
- button(type="submit") Go
+ input(id="file-input",type="file", name="video")
+ button(id="file-submit") Go
br
br
br
#player
video(id="player")
- source(src="/stream/Abv",type="video/webm")
+ source(src="/stream/abv",type="video/webm")
br
button(id="pause") Pause
9 uplawder.js
View
@@ -6,8 +6,11 @@ exports = module.exports = function uplawder(options) {
return function (req,res,next) {
if(req.method == 'GET' || req.method == 'HEAD') return next();
- //please be a form
- //
+ console.log(req.method);
+ console.log(req.url);
+ console.log(req.headers);
+
+ /*
var form = new formidable.IncomingForm;
Object.keys(options).forEach(function(key){
form[key] = options[key];
@@ -19,6 +22,6 @@ exports = module.exports = function uplawder(options) {
next();
};
- form.parse(req);
+ form.parse(req);*/
}
}

No commit comments for this range

Something went wrong with that request. Please try again.