Skip to content

Instantly share code, notes, and snippets.

@mebubo
Last active June 15, 2020 03:52
Show Gist options
  • Save mebubo/099d56c60d9a8569b6baad2499c8e4bc to your computer and use it in GitHub Desktop.
Save mebubo/099d56c60d9a8569b6baad2499c8e4bc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<!-- https://www.youtube.com/watch?v=6iVXaqUfHi4 -->
<html>
<body>
<div id="player"></div>
<br>
<button id="prev">&lt;</button>
<button id="next">&gt;</button>
<button id="save">s</button>
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '720',
width: '1280',
videoId: '6iVXaqUfHi4',
playerVars: { autoplay: 0, controls: 0, modestbranding: 1, rel: 0 },
events: {
'onReady': onPlayerReady,
}
});
}
function onPlayerReady(event) {
player.seekTo(timestamps[0], true)
}
function click(id, f) {
document.getElementById(id).onclick = f
}
click("prev", () => {
if (i > 0) {
player.seekTo(timestamps[--i], true)
}
console.log(timestamps[i]);
});
click("next", () => {
if (i < timestamps.length - 1) {
player.seekTo(timestamps[++i], true)
}
console.log(timestamps[i]);
});
click("save", () => {
let t = player.getCurrentTime()
newTimestamps.push(t)
console.log(newTimestamps)
});
let i = 0
let timestamps = [0, 56.88392104005432, 73.16802304768372, 87.38684498855591, 99.63631307152558, 113.5853930743866, 119.62112316021728, 125.45063815640259, 128.42789000953675, 136.10965207629394, 160.75755891130828, 172.74044703433228, 204.3531998884201, 223.07894705722046, 230.93132900858308, 249.13396988555908, 253.19777305149842, 310.23501794564055, 327.1968509446869, 334.6465988474121, 367.836444, 383.50033177111817, 396.00741817166136, 399.45271217738343, 402.03939403433225, 424.43794191703034, 446.4234920286102, 450.63072175681305, 455.69833414591216, 476.87497083406066, 486.427537879837, 509.46869897138976, 529.9618157739792, 544.4375982746582, 585.5344340286102, 601.2238147739791, 613.4775859513626, 626.6325311716614, 630.7044481516342, 668.7077328512268, 673.4608408254776, 722.7558381974106, 799.1539290085831, 807.2030889141693, 818.5539870314713, 825.1779188655319, 869.7962976938705, 891.0615270114441, 902.4943540886917, 923.5189191373291, 932.6951429341965, 956.6757719170304, 960.5131210486373, 1009.7429300572204, 1066.0798380801086, 1068.0767459351503, 1069.0997359370574, 1085.0975928254777, 1111.201584, 1128.8177959370576, 1134.2871052346038, 1173.2153881516342, 1178.4733501831054, 1226.309846874115, 1280.4872879198913, 1287.5933387940063, 1292.4360930400544, 1336.1299368540879, 1358.9136087997283, 1414.5058760486374, 1416.7627432202987, 1425.3922808941422, 1459.0468259485017]
let newTimestamps = []
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment