fetchTrackingWindow()
function fetchTrackingWindow(game, options): Promise<MetricaFrame[]>;Defined in: packages/data-providers/src/metrica/load.ts:452
Read a window of a sample game's frames without downloading either whole
file, using HTTP Range requests.
Six seconds around a goal is 150 frames. Measured against GitHub, reading
them takes about six requests and 220 KB, against 65 MB for the whole game.
Only plain bytes=start-end ranges are sent and no response header is
read, so it works cross-origin in a browser too.
const goal = shots(await fetchEvents(1)).find(isGoal)!;
const frames = await fetchTrackingWindow(1, {
fromFrame: goal["Start Frame"] - 125,
toFrame: goal["End Frame"],
});If the host ignores Range and sends a whole file back, that file is read
instead, so the result is the same, only slower.
Parameters
| Parameter | Type |
|---|---|
game | number |
options | TrackingWindowOptions |
Returns
Promise<MetricaFrame[]>