Browse Source

Implemented basic functionality for viewing a movie by viewing it in a table and getting a link to it via a get parameter.

pull/6/head
jrtechs 5 years ago
parent
commit
8003cc69bb
3 changed files with 44 additions and 6 deletions
  1. +23
    -0
      html/videos.html
  2. +1
    -1
      html/watch.html
  3. +20
    -5
      server.js

+ 23
- 0
html/videos.html View File

@ -0,0 +1,23 @@
<h1 class="text-center">Videos</h1>
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<td>Name</td>
<td>Length</td>
<td>Watch</td>
</tr>
</thead>
<tbody id="movieTable">
{for video in videos}
<tr>
<td>{video.name}</td>
<td>{video.length}</td>
<td>
<a href="/watch?v={video.name}" class="btn btn-secondary active" role="button" aria-pressed="true">View</a>
</td>
</tr>
{/for}
</tbody>
</table>

+ 1
- 1
html/watch.html View File

@ -1,3 +1,3 @@
<video id="videoPlayer" width="768" height="432" controls>
<source src="http://localhost:5000/video" type="video/mp4">
<source src="/video?v={videoURL}" type="video/mp4">
</video>

+ 20
- 5
server.js View File

@ -8,8 +8,8 @@ const fileIO = require('./fileIO');
const userUtils = require('./user.js');
const path = require('path');
const url = require('url');
const fs = require('fs');
@ -91,15 +91,30 @@ app.post('/login', function(request, result)
});
app.get('/videos', (req, res) => renderHTML(req, res, "videos.html", null));
app.get('/watch', (req, res) => renderHTML(req, res, "watch.html", null));
function getVideosTemplateInformation(templateContext, request)
{
templateContext.videos = [{name: "test1", length: 32},{name: "test2", length: 55}];
}
function getVideoTemplateInfo(templateContext, request)
{
templateContext.videoURL = request.query.v;
}
app.get('/videos', (req, res) => renderHTML(req, res, "videos.html", getVideosTemplateInformation));
app.get('/watch', (req, res) => renderHTML(req, res, "watch.html", getVideoTemplateInfo));
app.get('/video', function(request, result)
app.get('/video/', function(request, result)
{
if(request.session.login === true)
{
const path = '/home/jeff/public/CheckerMoves.mp4';
var videoID = request.query.v;
const path = '/home/jeff/public/Movies' + videoID;
console.log(path);
const stat = fs.statSync(path);
const fileSize = stat.size;
const range = request.headers.range;

Loading…
Cancel
Save