display comments from xml

This commit is contained in:
2021-01-27 00:17:59 +01:00
parent 9d8acd5e03
commit ffc9352f91
3 changed files with 57 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ class Controller {
"timeupdate",
function () {
this.view.videoPlayer.updateProgress();
this.getActiveComment();
}.bind(this)
);
video.addEventListener(
@@ -85,4 +86,24 @@ class Controller {
return this.model.parseXML(TheDocument);
}
getActiveComment() {
const video = document.getElementById("video");
let currentTime = Math.round(video.currentTime);
for (let i = 0; i < this.model.comments.length; i++) {
if (
currentTime > this.model.comments[i].start &&
currentTime < this.model.comments[i].end
) {
console.log("active: " + i);
this.view.activateComment(i);
this.view.activateCommentText(this.model.comments[i].fulltext);
return
} else {
this.view.activateComment(null);
this.view.activateCommentText(null);
}
}
}
}