</video>
<script>
+let now_playing = {};
const secondsSinceMidnight = ()=>{
const now = new Date();
return (now.getTime() - midnight.getTime()) / 1000;
};
+const updatePlayer = ()=>{
+ const duration = now_playing["curr"]["duration"];
+ const since_mn = secondsSinceMidnight();
+ const end_time = now_playing["start_time"] + duration;
+ const offset = duration - (end_time - since_mn);
+ if (offset > 0 && offset < duration)
+ {
+ Video.src = now_playing["curr"]["path"] + "#t=" + Math.floor(offset);
+ }
+};
+
const Cmd = {
play: (data)=>{
- console.log(data);
- const duration = data["curr"]["duration"];
- const since_mn = secondsSinceMidnight();
- const end_time = data["start_time"] + duration;
- const offset = duration - (end_time - since_mn);
- console.log(offset);
- if (offset > 0 && offset < duration)
- {
- Video.src = data["curr"]["path"] + "#t=" + Math.floor(offset);
- console.log(Video.src);
- }
+ now_playing = data;
+ updatePlayer();
}
};
const connect = ()=>{
- let ws = new WebSocket("ws://" + window.location.host);
+ let ws = new WebSocket(
+ "ws://" + window.location.host + ":3000");
+
ws.onmessage = (event)=>{
const msg = JSON.parse(event.data);
Cmd[msg.cmd](msg);
};
};
+Video.addEventListener("ended", updatePlayer);
+document.addEventListener("visibilitychange", updatePlayer);
(()=>{ connect(); })();
</script>
-</body></html>
\ No newline at end of file
+</body></html>
$now_playing = nil
$channel = 0
$channels = [
- { include: ["Christmas"] },
{ include: ["Movies", "Shorts", "Shows"] },
{ include: ["Movies"] },
{ include: ["Shorts"] },
{ include: ["Shows"] },
{ include: ["Pictures"] },
+ { include: ["Christmas"] },
]
def secs_since_midnight()