@@ -10,14 +10,22 @@ class Controller {
|
||||
let video = document.getElementById("video");
|
||||
|
||||
if (videoToLoad != null && videoToLoad != "") {
|
||||
this.loadVideo(videoToLoad).then(
|
||||
function () {
|
||||
video.addEventListener(
|
||||
"loadedmetadata",
|
||||
this.model.loadXml(videoToLoad).then(
|
||||
function (v) {
|
||||
let comments = this.model.parseXML(v);
|
||||
let videoFileName = this.model.getVideoFileName(v);
|
||||
this.view.drawCommentTitles(comments);
|
||||
this.addEventListeners();
|
||||
this.loadVideo(videoFileName).then(
|
||||
function () {
|
||||
this.view.videoPlayer.updateVideoDuration();
|
||||
this.addEventListenersToVideoControls();
|
||||
this.init(videoToLoad);
|
||||
video.addEventListener(
|
||||
"loadedmetadata",
|
||||
function () {
|
||||
this.view.videoPlayer.updateVideoDuration();
|
||||
this.view.drawCommentsToVideo(comments);
|
||||
this.addEventListenersToVideoControls();
|
||||
}.bind(this)
|
||||
);
|
||||
}.bind(this)
|
||||
);
|
||||
}.bind(this)
|
||||
@@ -28,21 +36,14 @@ class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
init(videoToLoad) {
|
||||
this.loadXml(videoToLoad).then(
|
||||
function (v) {
|
||||
this.view.drawCommentTitles(v);
|
||||
this.addEventListeners();
|
||||
this.view.drawCommentsToVideo(v);
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
addEventListenersToAddVideo() {
|
||||
let form = document.getElementById("form");
|
||||
form.addEventListener("submit", function () {
|
||||
document.getElementById("xmlFile").value = this.view.editor.getValue();
|
||||
}.bind(this));
|
||||
form.addEventListener(
|
||||
"submit",
|
||||
function () {
|
||||
document.getElementById("xmlFile").value = this.view.editor.getValue();
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
// Přidání listenerů
|
||||
@@ -121,28 +122,13 @@ class Controller {
|
||||
|
||||
video.classList.remove("hidden");
|
||||
|
||||
source.setAttribute("src", "./videos/" + v + ".webm");
|
||||
source.setAttribute("src", "./videos/" + v);
|
||||
video.append(source);
|
||||
|
||||
await video.load();
|
||||
this.view.createVideoPlayerObject();
|
||||
}
|
||||
|
||||
async loadXml(v) {
|
||||
var Connect = new XMLHttpRequest();
|
||||
// Define which file to open and
|
||||
// send the request.
|
||||
Connect.open("GET", "./videos/" + v + ".xml", false);
|
||||
Connect.setRequestHeader("Content-Type", "text/xml");
|
||||
Connect.send(null);
|
||||
// Place the response in an XML document.
|
||||
var TheDocument = Connect.responseText;
|
||||
// Place the root node in an element.
|
||||
// var Customers = TheDocument.childNodes[0];
|
||||
|
||||
return this.model.parseXML(TheDocument);
|
||||
}
|
||||
|
||||
getActiveComment() {
|
||||
const video = document.getElementById("video");
|
||||
let currentTime = video.currentTime;
|
||||
|
||||
25
js/model.js
25
js/model.js
@@ -19,4 +19,29 @@ class Model {
|
||||
|
||||
return this.comments;
|
||||
}
|
||||
|
||||
getVideoFileName(xml) {
|
||||
let parser = new DOMParser();
|
||||
let xmlDoc = parser.parseFromString(xml, "text/xml");
|
||||
let videoTag = xmlDoc.activeElement.getAttribute("src");
|
||||
|
||||
return videoTag;
|
||||
}
|
||||
|
||||
getCommentsObjects() {}
|
||||
|
||||
async loadXml(v) {
|
||||
var Connect = new XMLHttpRequest();
|
||||
// Define which file to open and
|
||||
// send the request.
|
||||
Connect.open("GET", "./videos/" + v + ".xml", false);
|
||||
Connect.setRequestHeader("Content-Type", "text/xml");
|
||||
Connect.send(null);
|
||||
// Place the response in an XML document.
|
||||
var TheDocument = Connect.responseText;
|
||||
// Place the root node in an element.
|
||||
// var Customers = TheDocument.childNodes[0];
|
||||
|
||||
return TheDocument;
|
||||
}
|
||||
}
|
||||
|
||||
12
upload.php
12
upload.php
@@ -26,11 +26,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
move_uploaded_file(
|
||||
$_FILES["videoFile"]["tmp_name"],
|
||||
"videos/R-" .
|
||||
"videos/" .
|
||||
$generatedFileName . "." . $extension
|
||||
);
|
||||
writeToFile("videos/" . $generatedFileName . ".xml", $_POST["xmlFile"]);
|
||||
shell_exec("./transcode.sh > /dev/null 2>&1 &");
|
||||
$xml = $_POST["xmlFile"];
|
||||
$xml = str_replace("<video>", '<video src="' . $generatedFileName . '.' . $extension . '">', $xml);
|
||||
|
||||
writeToFile("videos/" . $generatedFileName . ".xml", $xml);
|
||||
redirect("?v=" . $generatedFileName);
|
||||
}
|
||||
} else {
|
||||
@@ -40,7 +42,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
redirect();
|
||||
}
|
||||
|
||||
function writeToFile($file, $xml) {
|
||||
function writeToFile($file, $xml)
|
||||
{
|
||||
$myfile = fopen($file, "w") or die("Unable to open file!");
|
||||
$txt = "John Doe\n";
|
||||
fwrite($myfile, $xml);
|
||||
@@ -63,4 +66,3 @@ function generateRandomString($length = 4)
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user