-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (38 loc) · 1.11 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
<script>
const getMediaTime = () => new Promise(resolve => {
const video = document.getElementsByTagName('video')[0];
if (!video) return;
video.requestVideoFrameCallback((now, metadata) => {
resolve(metadata.mediaTime);
})
});
window.jumpPrevFrame = async () => {
const video = document.getElementsByTagName('video')[0];
if (!video) return;
video.currentTime += 1;
video.currentTime -= 1;
const firstMediaTime = await getMediaTime();
for (;;) {
video.currentTime -= 0.01;
if ((await getMediaTime()) !== firstMediaTime) {
break;
}
}
}
window.jumpNextFrame = async () => {
const video = document.getElementsByTagName('video')[0];
if (!video) return;
video.currentTime += 1;
video.currentTime -= 1;
const firstMediaTime = await getMediaTime();
for (;;) {
video.currentTime += 0.01;
if ((await getMediaTime()) !== firstMediaTime) break;
}
}
</script>
<video src="./25fps.mp4" muted="true" playsInline="true" preload="auto"></video>
<div>
<button onclick="jumpPrevFrame()">PREV_FRAME</button>
<button onclick="jumpNextFrame()">NEXT_FRAME</button>
</div>