-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (57 loc) · 1.75 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>videoWatcher.js</title>
</head>
<body>
<div id="wrapper"></div>
<ul id="watchList"></ul>
<script src="js/videoWatcher.js"></script>
<script>
var videoSrc = 'https://wwwcontent.ad2iction.com/han/video/maze10.mp4';
var video = videoWatcher(videoSrc, [
'0sec',
'1sec',
'1.5sec',
'3sec',
'5500ms',
'75%',
'100%'
]);
video.width = 320;
video.controls = true;
function log(msg) {
var li = document.createElement('li');
li.textContent = msg;
console.log(msg);
watchList.appendChild(li);
}
// 偵聽事件 'progress:' + 指定的時間點
video.addEventListener('progress:0sec', function(e) {
log(e.detail.original);
});
video.addEventListener('progress:1sec', function(e) {
log(e.detail.original);
});
video.addEventListener('progress:1.5sec', function(e) {
log(e.detail.original);
});
video.addEventListener('progress:3sec', function(e) {
log(e.detail.original);
});
video.addEventListener('progress:5500ms', function(e) {
log(e.detail.original);
});
video.addEventListener('progress:75%', function(e) {
log(e.detail.original);
});
video.addEventListener('progress:100%', function(e) {
log(e.detail.original);
});
wrapper.appendChild(video);
video.play();
</script>
</body>
</html>