Skip to content

Commit da232c5

Browse files
committedAug 29, 2023
example
1 parent 1ce1cec commit da232c5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
 

‎25fps.mp4

4.17 MB
Binary file not shown.

‎index.html

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<script>
2+
3+
const getMediaTime = () => new Promise(resolve => {
4+
const video = document.getElementsByTagName('video')[0];
5+
if (!video) return;
6+
video.requestVideoFrameCallback((now, metadata) => {
7+
resolve(metadata.mediaTime);
8+
})
9+
});
10+
11+
window.jumpPrevFrame = async () => {
12+
const video = document.getElementsByTagName('video')[0];
13+
if (!video) return;
14+
15+
video.currentTime += 1;
16+
video.currentTime -= 1;
17+
const firstMediaTime = await getMediaTime();
18+
19+
20+
for (;;) {
21+
video.currentTime -= 0.01;
22+
if ((await getMediaTime()) !== firstMediaTime) {
23+
break;
24+
}
25+
}
26+
27+
}
28+
29+
window.jumpNextFrame = async () => {
30+
const video = document.getElementsByTagName('video')[0];
31+
if (!video) return;
32+
33+
34+
35+
video.currentTime += 1;
36+
video.currentTime -= 1;
37+
const firstMediaTime = await getMediaTime();
38+
39+
for (;;) {
40+
video.currentTime += 0.01;
41+
if ((await getMediaTime()) !== firstMediaTime) break;
42+
}
43+
44+
45+
}
46+
</script>
47+
48+
<video src="./25fps.mp4" muted="true" playsInline="true" preload="auto"></video>
49+
<div>
50+
<button onclick="jumpPrevFrame()">PREV_FRAME</button>
51+
<button onclick="jumpNextFrame()">NEXT_FRAME</button>
52+
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.