Skip to content

Commit

Permalink
Merge pull request #76 from nus-mtp/develop
Browse files Browse the repository at this point in the history
Merge develop to master for Sprint 3 release
  • Loading branch information
linxea committed Mar 2, 2016
2 parents 1e53d33 + 359af3e commit 4598158
Show file tree
Hide file tree
Showing 55 changed files with 2,201 additions and 433 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ node_js:

before_install: npm install -g grunt-cli

install: npm install
install:
- npm install
- bower install

script: grunt test

Expand Down
53 changes: 20 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,48 @@
# zoomable.js [![Build Status][travis-image]][travis-url]
An open source Javascript-based zoomable video player and server, which utilizes websocket and DASH to stream videos for playback. A zoomable video player is a video player that allows user to zoom into and pan around the video to view selected in higher resolution and in more details.

This is an open-source HTML5 video player that allows users to zoom in with greater detail and pan around the video with bandwith efficiency. The Javascript-based zoomable video player streams dash-compliant videos and adapts to network conditions to provide continuous video playback by reducing the video resolutions where necessary.

## Installation

### Prerequisites

[Node.js](http://nodejs.org)

Install Node.js from https://nodejs.org/en/download/

If you have Homebrew installed:
```bash
$ brew install node
```

[Grunt](http://gruntjs.com/)
```bash
$ npm install -g grunt-cli
```
### Step 1: Cloning the project

[Bower](http://www.npmjs.com/package/bower)
```bash
$ npm install -g bower
```
Pull a copy of this project from GitHub (link above) or download the project as a zipped folder (Download ZIP above) to your computer.

[Sails.js](http://sailsjs.org/get-started)
```bash
$ npm install -g sails
```
### Step 2: Installing the necessary pre-requisites

#### The following packages are required for using zoomable.js:
[Node.js](http://nodejs.org) - For package installation
[Grunt](http://gruntjs.com/) - For generating front-end assets
[Bower](http://www.npmjs.com/package/bower) - For package installation
[Sails.js](http://sailsjs.org/get-started) - For server creation
[FFMPEG](https://ffmpeg.org/download.html) - For video conversion, thumnbnail generation
[MP4Box](https://gpac.wp.mines-telecom.fr/downloads/) - For MPD creation for the videos

### Setup
### Step 3: Install additional dependencies and libraries

Install the necessary packages.
Run the npm and bower install commands to install the dependencies and libraries that the project requires. These dependencies and libraries are indicated inside package.json (for npm install) and bower.json (for bower install).

For bash:
```bash
$ npm install
$ bower install
```

### Task Automation

Generate frontend assets using Grunt.
### Step 4: Generate latest front-end assets

Run the Grunt command to update the changes made to the front-end assets and compile it for further use later.
```bash
$ grunt
```

### Start server

Run on http://localhost:1337 .
### Step 5: Starting the server

Start the server by running the Sails command:
```bash
$ sails lift
```

If this server is setup locally, open your browser and enter the url: [http://localhost:1337](http://localhost:1337) to visit the main webpage of the project.

## Usage
`to be updated`

Expand Down
36 changes: 26 additions & 10 deletions api/controllers/PageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ module.exports = {

// If not logged in, show the public view.
if (!req.session.me) {
//return res.view('homepage');
return res.view('homepage', {
me: [],
user: [],
video: []
});
}
Expand All @@ -28,15 +27,19 @@ module.exports = {

if (!user) {
sails.log.verbose('Session refers to a user who no longer exists- did you delete a user, then try to refresh the page with an open tab logged-in as that user?');
//return res.view('homepage');
return res.view('homepage', {
me: [],
user: [],
video: []
});
}

// returned filtered user object
var userObj = {
username: user.username,
email: user.email
};
return res.view('dashboard', {
me: user,
user: userObj,
video: []
});

Expand All @@ -47,7 +50,10 @@ module.exports = {

// If not logged in, show the public view.
if (!req.session.me) {
return res.view('homepage');
return res.view('homepage', {
user: [],
video: []
});
}

// Otherwise, look up the logged-in user and show the logged-in view,
Expand All @@ -60,7 +66,7 @@ module.exports = {
if (!user) {
sails.log.verbose('Session refers to a user who no longer exists- did you delete a user, then try to refresh the page with an open tab logged-in as that user?');
return res.view('homepage', {
me: [],
user: [],
video: []
});
}
Expand All @@ -71,14 +77,24 @@ module.exports = {
// return error
}

// if successful, return user and video object to frontend
// if successful, return filtered user and video object to frontend
var userObj = {
username: user.username,
email: user.email
};
return res.view('edit', {
me: user,
user: userObj,
video: video
});

});
});
}
},

showPlayerPage: function (req, res) {
return res.view('fullplayer', {
user: [],
video: []
});
}
};
45 changes: 45 additions & 0 deletions api/controllers/ProcessingController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* ProcessingController
*
* @description :: Server-side logic for managing processings
* @help :: See http://links.sailsjs.org/docs/controllers
*/

var spawn = require('child_process').spawn;

module.exports = {

/**
* Usage: POST /api/processing/run
* Content: {dir: ':dir', filename: ':filename'}
**/
run: function (req, res) {
var dirPath = req.param('dir');
var fileName = sails.getBaseUrl() + '/' + req.param('filename');

var command = spawn(sails.config.appPath + '/scripts/video-processing.sh', [dirPath]);

command.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
});

command.stderr.on('data', function(chunk) {
console.log('stderr: ' + chunk);
// res.send(500); // when script fails, generate a Server Error HTTP res
});

command.on('close', function(chunk) {
// return json contains mpdDir and thumbnailDir
res.json({
mpdDir: [
filename+'_mpd_R1C1.mpd', filename+'_mpd_R1C2.mpd', filename+'_mpd_R1C3.mpd', filename+'_mpd_R1C4.mpd',
filename+'_mpd_R2C1.mpd', filename+'_mpd_R2C2.mpd', filename+'_mpd_R2C3.mpd', filename+'_mpd_R2C4.mpd',
filename+'_mpd_R3C1.mpd', filename+'_mpd_R3C2.mpd', filename+'_mpd_R3C3.mpd', filename+'_mpd_R3C4.mpd',
filename+'_mpd_R4C1.mpd', filename+'_mpd_R4C2.mpd', filename+'_mpd_R4C3.mpd', filename+'_mpd_R4C4.mpd'
],
thumbnailDir: filename + '.png'
});
});
}
};

40 changes: 37 additions & 3 deletions api/controllers/VideoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

module.exports = {

/**
* `VideoController.create()`
* Usage: POST /api/video
Expand Down Expand Up @@ -36,6 +36,7 @@ module.exports = {
* Usage: GET /api/video
*/
readAll: function (req, res) {
console.log(sails.getBaseUrl());
Video.find().exec(function (err, videos) {
if (err) throw err;
res.json(videos);
Expand Down Expand Up @@ -72,7 +73,7 @@ module.exports = {

/**
* `VideoController.tags()`
* Usage:
* Usage:
*/
tags: function (req, res) {
return res.json({
Expand All @@ -92,6 +93,39 @@ module.exports = {
if (err) throw err;
res.json(video.videoDir);
});
},

/**
* `VideoController.upload()`
* Usage: POST /api/video/upload
* Content: {id: ':id', video: 'attach video file here'}
**/
upload: function (req, res) {
req.file('video').upload({
dirname: sails.config.appPath + '/.tmp/public/upload/vid/' + req.param('id'),
maxBytes: 2 * 1000 * 1000 * 1000
}, function (err, uploadedFiles) {
if (err) return res.negotiate(err);

// If no files were uploaded, respond with an error.
if (uploadedFiles.length === 0){
return res.badRequest('No file was uploaded');
}

// Update the Video Model's videoDir based on the video ID
Video.update({
id: req.param('id')
}, {
videoDir: uploadedFiles[0].fd
}).exec(function (err, updatedVideo) {
return res.json({
message: uploadedFiles.length + ' file(s) uploaded successfully!',
// Only upload 1 video per time
files: uploadedFiles[0],
textParams: req.params.all(),
video: updatedVideo[0]
});
});
});
}
};

8 changes: 3 additions & 5 deletions api/models/Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ module.exports = {
defaultsTo: 0
},

videoDir: {
type: 'string',
required: true
mpdDir: {
type: 'string'
},

thumbnailDir: {
type: 'string',
required: true
type: 'string'
},

createdAt: {
Expand Down
12 changes: 12 additions & 0 deletions assets/images/ic_caption.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/images/ic_clear_white_24px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/images/ic_delete_black_24px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/images/ic_fullscreen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/images/ic_fullscreen_exit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/images/ic_pause.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/images/ic_play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/images/ic_replay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions assets/images/ic_setting.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4598158

Please sign in to comment.