-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
executable file
·48 lines (47 loc) · 1.01 KB
/
index.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
<html>
<head>
<style>
body {
margin:0;
}
</style>
</head>
<body>
<canvas id="canvas">
</canvas>
<script>
(function(){
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var videos = ["Razer.mp4", "miku.mp4"];
var videoElements = videos.map(function(video) {
var e = document.createElement("video");
e.src = video;
e.addEventListener("ended", play);
return e;
});
var index = -1;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
function play() {
if(++index >= videos.length){
index = 0;
}
var element = videoElements[index];
//element.currentTime = 0;
ctx.globalAlpha = 0;
element.play();
}
play();
function tick() {
if(ctx.globalAlpha < 1){
ctx.globalAlpha += 0.01;
}
ctx.drawImage(videoElements[index],0,0,canvas.width,canvas.height);
setTimeout(tick, 50);
}
tick();
})();
</script>
</body>
</html>