WICG / video-rvfc

video.requestVideoFrameCallback() incubation
https://wicg.github.io/video-rvfc/
Other
54 stars 19 forks source link

callback when video paused and/or off-screen? #53

Closed gabe97330 closed 4 years ago

gabe97330 commented 4 years ago

The spec talks about the video "playing". Does this mean that use cases like scrubbing where you seek to a frame while paused will not generate a callback?

tguilbert-google commented 4 years ago

If a video is paused, seeking to a frame should cause the callbacks to fire once. You should however make sure to call requestVideoFrameCallback() before seeking, because if the seek completes before the callbacks are attached, the callbacks will never fire (until a new seek is issued at least, which might not happen if you were queuing the next seek from within your callback).

The same should be true if the video element is not onscreen or attached to a document (although, the Chromium code to make that work will only be present starting with the M84 release).

The part about "best effort with the video playing on screen" is there to clarify the scenarios in which, for example, there is both a <video> and a <canvas> on screen. If you call drawImage on the canvas from a VideoFrameCallback, it will occasionally be 1/60th of a second (assuming a 60hz monitor) behind the video.

I hope this answers your question! I am marking this issue as closed for now, but will reopen it if need.

gabe97330 commented 4 years ago

Thanks, your answer was helpful! I have some related questions but will file them separately.

lincolnneu commented 3 years ago

If a video is paused, seeking to a frame should cause the callbacks to fire once.

Is this guaranteed or also best effort?

dalecurtis commented 3 years ago

When paused you're guaranteed to get the on screen frame in the callback; it may just be a vsync late.