-
Notifications
You must be signed in to change notification settings - Fork 0
/
viddycast.html
69 lines (63 loc) · 2.35 KB
/
viddycast.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html><head>
<title>StreamVid Test HLS Player</title>
<link href="movienight-assets/video-js.min.css" rel="stylesheet">
<script src="movienight-assets/video.min.js"></script>
<script src="movienight-assets/hls.js/dist/hls.min.js"></script>
<script src="movienight-assets/videojs-hlsjs.js"></script>
<script src="movienight-assets/fetch.min.js"></script>
<style>
html, body { width: 100%; height: 100%; padding: 0; margin: 0; border: 0; }
#video { width: 100%; height: 100%; }
div.video-js button.vjs-big-play-button,
div.video-js .vjs-captions-button { display: none }
</style>
</head><body bgcolor="#070707">
<video id="video" controls class="video-js vjs-default-skin"></video>
<script>
var title = location.hash.split('#')[1].replace(/[^a-z0-9_-]/i, '');
var placeholderVideo = {src: "viddycast-ObiWanKeighobi-Countdown.mp4", type: "video/mp4"};
var player = videojs('video');
player.ready(function() {
this.loop(true);
this.volume(0);
this.src(placeholderVideo);
this.play();
lookForPresentation();
});
player.on("loadedmetadata", function() { player.play() });
// when video is done playing, reload the page and return to the waiting loading state
player.on("ended", function() {
setTimeout(function() {
location.reload();
}, 60000);
});
// start checking if presentation has started streaming
var lookForPresentationInterval = 2500;
function lookForPresentation() {
// test if the live streams have started existing yet...
var opts = { method: 'POST' };
fetch("presentation/"+title+"/stream-A-.m3u8", opts).then(function(response) { // success handler
if (response.status != 404) {
// if they do exist, tell the player to change url to new video
player.src({type: 'application/x-mpegURL', src: "presentation/"+title+"/stream.m3u8"});
player.loop(false);
player.volume(1);
} else {
// play the loop
if (player.loop() == false) {
this.loop(true);
this.volume(0);
this.src(placeholderVideo);
this.play();
}
console.log("Presentation not yet available...", response);
setTimeout(lookForPresentation, lookForPresentationInterval); // 404 or whatever
}
}, function(err) { // error handler
console.error("Connection error", err);
setTimeout(lookForPresentation, lookForPresentationInterval);
});
}
</script>
</body></html>