-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo.html
38 lines (37 loc) · 901 Bytes
/
video.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>fillRect</title>
<style>
canvas {
border: 1px solid #d9d9d9;
}
</style>
</head>
<body>
<video id="video" width="320" height="240" controls>
<source src="images/movie.mp4" type="video/mp4">
</video>
<canvas id="canvas" width="400" height="300">
不支持canvas
</canvas>
<script>
var canvas = document.getElementById('canvas');
var ctx = '';
ctx = canvas.getContext('2d');
var video = document.getElementById('video');
var times = video.duration;
var t = 0;
var timeId = setInterval(function() {
if (t > times) {
clearInterval(timeId);
} else {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(video, 0, 0);
t += 100;
}
}, 100)
</script>
</body>
</html>