Legacy requestVideoFrameCallback polyfill using requestAnimationFrame + video.currentTime.
npm install rvfc-legacy-polyfillLegacy HTMLVideoElement.requestVideoFrameCallback polyfill using requestAnimationFrame + video.currentTime.
* Adds requestVideoFrameCallback / cancelVideoFrameCallback only 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 currentTime changes when counters are not available.
* Reports mediaTime as video.currentTime (no RAF-based drift correction).
``bash`
npm i rvfc-legacy-polyfill
Import once at startup (side-effect import):
`js`
import "rvfc-legacy-polyfill";
Or in CommonJS:
`js`
require("rvfc-legacy-polyfill");
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).
This package ships as plain JS (no build step). If your target browser requires transpilation/polyfills, your app/bundler must provide them.
Apache-2.0