rvfc-legacy-polyfill
v0.1.0
Published
Legacy requestVideoFrameCallback polyfill using requestAnimationFrame + video.currentTime.
Downloads
102
Maintainers
Readme
rvfc-legacy-polyfill
Legacy HTMLVideoElement.requestVideoFrameCallback polyfill using requestAnimationFrame + video.currentTime.
What it does
- Adds
requestVideoFrameCallback/cancelVideoFrameCallbackonly if the browser does not provide native RVFC. - Uses frame counters when available (
getVideoPlaybackQuality,webkitDecodedFrameCount,mozPresentedFrames/mozPaintedFrames) to detect new presented frames more reliably. - Falls back to
currentTimechanges when counters are not available. - Reports
mediaTimeasvideo.currentTime(no RAF-based drift correction).
Install
npm i rvfc-legacy-polyfillUsage
Import once at startup (side-effect import):
import "rvfc-legacy-polyfill";Or in CommonJS:
require("rvfc-legacy-polyfill");Notes / Accuracy
This polyfill runs on requestAnimationFrame, so timestamps are window-framerate-bound and not decoder-accurate. It may:
- introduce jitter,
- miss frames when video FPS > display FPS,
- report renderer-aligned timestamps (not true decode timestamps).
Compatibility
This package ships as plain JS (no build step). If your target browser requires transpilation/polyfills, your app/bundler must provide them.
License
Apache-2.0
