elm-twitch/index.html

54 lines
1.8 KiB
HTML
Raw Normal View History

2020-10-03 18:44:16 +02:00
<!doctype HTML>
<html>
<head>
<title>twitch.tforgione.fr</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2020-11-05 17:23:42 +01:00
<link rel="icon" type="image/ico" href="/favicon.ico"/>
2020-10-04 16:37:01 +02:00
<link href="css/video-js.css" rel="stylesheet">
2020-10-04 21:09:13 +02:00
<link href="css/spinner.css" rel="stylesheet">
2020-10-03 18:44:16 +02:00
</head>
<body>
<div id="container"></div>
2020-10-04 16:37:01 +02:00
<script src="js/vd.js"></script>
2020-10-03 18:44:16 +02:00
<script src="js/main.js"></script>
<script>
2020-10-04 16:37:01 +02:00
var app = Elm.Main.init({
2020-10-04 20:20:16 +02:00
node: document.getElementById('container'),
flags: { width: window.innerWidth, height: window.innerHeight }
2020-10-03 18:44:16 +02:00
});
2020-10-04 16:37:01 +02:00
2020-10-04 21:31:16 +02:00
var lastId, player;
2020-10-04 23:03:38 +02:00
if (app.ports !== undefined && app.ports.registerVideo !== undefined) {
app.ports.registerVideo.subscribe(function(args) {
2020-10-06 18:32:10 +02:00
window.scrollTo(0, 0);
var time = vd.parseTime(args[2]) || undefined;
2020-10-04 21:31:16 +02:00
2020-10-04 23:03:38 +02:00
requestAnimationFrame(function() {
if (args[0] !== lastId) {
lastId = args[0];
2020-10-04 21:31:16 +02:00
2020-10-04 23:03:38 +02:00
player = vd.setup(args[0], {
2021-03-24 08:17:36 +01:00
v: args[1] + "/manifest.m3u8",
2020-11-05 17:18:16 +01:00
t: time,
2020-10-06 09:54:34 +02:00
focus: true
2020-10-04 23:03:38 +02:00
});
} else if (time !== undefined ){
player.currentTime(time);
}
});
2020-10-04 17:06:03 +02:00
});
2020-10-04 23:03:38 +02:00
}
2020-10-05 11:26:11 +02:00
if (app.ports !== undefined && app.ports.eraseVideo !== undefined) {
app.ports.eraseVideo.subscribe(function() {
2020-10-06 18:32:10 +02:00
window.scrollTo(0, 0);
2020-10-05 11:26:11 +02:00
lastId = undefined;
});
}
2020-10-03 18:44:16 +02:00
</script>
</body>
</html>