player.js: Remove parsing
Also init the YouTube player as soon as possible
This commit is contained in:
parent
6d812975b2
commit
6d3c2ea785
|
@ -3,12 +3,15 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|
||||||
<!-- Load the player -->
|
<!-- Load the player -->
|
||||||
<script type="text/javascript" src="player.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
<link rel="stylesheet" type="text/css" href="riscy.css">
|
<link rel="stylesheet" type="text/css" href="riscy.css">
|
||||||
<link rel="stylesheet" type="text/css" href="topics.css">
|
<link rel="stylesheet" type="text/css" href="topics.css">
|
||||||
|
<script type="text/javascript" src="player.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<script>
|
||||||
|
Player.initializeYoutube(function() {});
|
||||||
|
</script>
|
||||||
<div class="title riscy">
|
<div class="title riscy">
|
||||||
<span class="episode_name">Coloured Nicks</span>
|
<span class="episode_name">Coloured Nicks</span>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
|
@ -214,7 +217,8 @@ for (var i = 0; i < refTimecodes.length; ++i) {
|
||||||
NOTE(matt): The filter system will need to know whether we are inclusive or exclusive, which it gets / sets from that classList
|
NOTE(matt): The filter system will need to know whether we are inclusive or exclusive, which it gets / sets from that classList
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var filterModeElement = document.querySelector(".filter_mode");
|
var filter = document.querySelector(".filter");
|
||||||
|
var filterModeElement = filter.querySelector(".filter_mode");
|
||||||
var filterMode = filterModeElement.classList[1];
|
var filterMode = filterModeElement.classList[1];
|
||||||
filterModeElement.addEventListener("click", function(ev) {
|
filterModeElement.addEventListener("click", function(ev) {
|
||||||
if(filterMode == "inclusive")
|
if(filterMode == "inclusive")
|
||||||
|
|
|
@ -139,94 +139,6 @@ Player.prototype.resume = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.createHTMLSkeleton = function(videoId, markers) {
|
|
||||||
};
|
|
||||||
|
|
||||||
// timestamp can be either an int (number of seconds from beginning of the video) or a string ([hh:][mm:]ss)
|
|
||||||
Player.createHTMLMarker = function(timestamp, text, ref) {
|
|
||||||
if (typeof(timestamp) == "string") {
|
|
||||||
var timeParts = timestamp.split(":");
|
|
||||||
var hours = (timeParts.length == 3 ? parseInt(timeParts[0], 10) : 0);
|
|
||||||
var minutes = (timeParts.length > 1 ? parseInt(timeParts[timeParts.length-2], 10) : 0);
|
|
||||||
var seconds = parseInt(timeParts[timeParts.length-1], 10);
|
|
||||||
timestamp = hours * 60 * 60 + minutes * 60 + seconds;
|
|
||||||
}
|
|
||||||
var marker = document.createElement("DIV");
|
|
||||||
marker.classList.add("marker");
|
|
||||||
marker.setAttribute("data-timestamp", timestamp);
|
|
||||||
if (ref !== undefined && ref !== null) {
|
|
||||||
marker.setAttribute("data-ref", ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
var content = document.createElement("DIV");
|
|
||||||
content.classList.add("content");
|
|
||||||
|
|
||||||
var markerTime = "(";
|
|
||||||
var hours = Math.floor(timestamp / 60 / 60);
|
|
||||||
var minutes = Math.floor(timestamp / 60) % 60;
|
|
||||||
var seconds = timestamp % 60;
|
|
||||||
if (hours > 0) {
|
|
||||||
markerTime += (hours < 10 ? "0" + hours : hours) + ":";
|
|
||||||
}
|
|
||||||
markerTime += (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + ")";
|
|
||||||
|
|
||||||
content.textContent = markerTime + " " + text;
|
|
||||||
marker.appendChild(content);
|
|
||||||
|
|
||||||
var fadedProgress = document.createElement("DIV");
|
|
||||||
fadedProgress.classList.add("progress");
|
|
||||||
fadedProgress.classList.add("faded");
|
|
||||||
fadedProgress.appendChild(content.cloneNode(true));
|
|
||||||
marker.appendChild(fadedProgress);
|
|
||||||
|
|
||||||
var progress = document.createElement("DIV");
|
|
||||||
progress.classList.add("progress");
|
|
||||||
progress.classList.add("main");
|
|
||||||
progress.appendChild(content.cloneNode(true));
|
|
||||||
marker.appendChild(progress);
|
|
||||||
|
|
||||||
|
|
||||||
return marker;
|
|
||||||
};
|
|
||||||
|
|
||||||
Player.parseHMHAnnotation = function(text) {
|
|
||||||
var annotation = {
|
|
||||||
title: null,
|
|
||||||
videoId: null,
|
|
||||||
author: null,
|
|
||||||
markers: []
|
|
||||||
};
|
|
||||||
|
|
||||||
var lines = text.split("\n");
|
|
||||||
var mode = "none";
|
|
||||||
for (var i = 0; i < lines.length; ++i) {
|
|
||||||
var line = lines[i];
|
|
||||||
if (line == "---") {
|
|
||||||
mode = "none";
|
|
||||||
} else if (line.startsWith("title:")) {
|
|
||||||
annotation.title = line.slice(7).replace(/"/g, "");
|
|
||||||
} else if (line.startsWith("videoId:")) {
|
|
||||||
annotation.videoId = line.slice(9).replace(/"/g, "");
|
|
||||||
} else if (line.startsWith("author:")) {
|
|
||||||
annotation.author = line.slice(8).replace(/"/g, ""); // Miblo, where's the author field?
|
|
||||||
} else if (line.startsWith("markers")) {
|
|
||||||
mode = "markers";
|
|
||||||
} else if (mode == "markers") {
|
|
||||||
var match = line.match(/"((\d+):)?(\d+):(\d+)": "(.+)"/);
|
|
||||||
var marker = {
|
|
||||||
timestamp: (match[2] ? parseInt(match[2], 10) : 0) * 60 * 60 + parseInt(match[3], 10) * 60 + parseInt(match[4], 10),
|
|
||||||
text: match[5].replace(/\\"/g, "\"")
|
|
||||||
}
|
|
||||||
annotation.markers.push(marker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return annotation;
|
|
||||||
};
|
|
||||||
|
|
||||||
Player.parseAnnotation = function(text) {
|
|
||||||
};
|
|
||||||
|
|
||||||
Player.initializeYoutube = function(callback) {
|
Player.initializeYoutube = function(callback) {
|
||||||
if (window.APYoutubeAPIReady === undefined) {
|
if (window.APYoutubeAPIReady === undefined) {
|
||||||
window.APYoutubeAPIReady = false;
|
window.APYoutubeAPIReady = false;
|
||||||
|
|
Loading…
Reference in New Issue