-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(screencast): more tests on Chromium, new seek impl (#3699)
- Loading branch information
Showing
2 changed files
with
113 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<script> | ||
async function playToTheEnd() { | ||
const video = document.querySelector('video'); | ||
const result = new Promise(r => video.onended = r); | ||
video.play(); | ||
return await result; | ||
} | ||
|
||
async function playOneFrame() { | ||
const video = document.querySelector('video'); | ||
const result = new Promise(r => video.onpause = r); | ||
video.ontimeupdate = () => { | ||
video.pause(); | ||
video.ontimeupdate = null; | ||
}; | ||
video.play(); | ||
return await result; | ||
} | ||
|
||
async function playNFrames(n) { | ||
for (let i = 0; i < n; i++) | ||
await playOneFrame(); | ||
} | ||
|
||
async function countFrames() { | ||
const video = document.querySelector('video'); | ||
|
||
if (!video.duration) | ||
return 0; | ||
|
||
if (video.currentTime) | ||
await playToTheEnd(); | ||
|
||
let count = 0; | ||
while (true) { | ||
++count; | ||
await playOneFrame(); | ||
if (video.ended) | ||
break; | ||
} | ||
return count; | ||
} | ||
|
||
async function seekLastFrame() { | ||
const frameCount = await countFrames(); | ||
await playNFrames(frameCount); | ||
return frameCount; | ||
} | ||
|
||
</script> | ||
<body> | ||
<video controls> | ||
<source src="v.webm" type="video/webm"> | ||
Your browser does not support HTML video. | ||
</video> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters