# `PhoenixReplay.Export.Schedule`
[🔗](https://github.com/elixir-vibe/phoenix_replay/blob/v0.6.2/lib/phoenix_replay/export/schedule.ex#L1)

Which moments of a recording a video shows, and for how long.

The video runs at a constant frame rate from the first render to the
end of the recording or its pointer track, and holds the last moment
for `:hold` milliseconds so it is seen. Each frame shows the moment
of the recording it falls on, except that a stretch without activity
longer than `:idle` is shortened to `:idle`, half of it after the
activity before and half before the activity after.

Consecutive frames that would look the same share one `t:shot/0`: the
same event, the same scroll position, the same pointer presses and
moves, and no pointer animation running. While the pointer moves, and
for as long as its trail and press ripples take to fade, every frame is
a shot of its own. So capturing takes a screenshot per shot, not per
frame.

# `shot`

```elixir
@type shot() :: %{
  index: non_neg_integer(),
  at: non_neg_integer(),
  viewport: %{
    :width =&gt; pos_integer(),
    :height =&gt; pos_integer(),
    optional(:media) =&gt; %{required(String.t()) =&gt; String.t()}
  },
  frames: pos_integer()
}
```

One screenshot: the event `index` and the moment `at` of the recording
to show, the `viewport` the page had, with its media features when they
were recorded (see `PhoenixReplay.Recording.Client.media/1`), and how
many `frames` it lasts.

# `t`

```elixir
@type t() :: %PhoenixReplay.Export.Schedule{
  canvas: %{width: pos_integer(), height: pos_integer()},
  dpr: number(),
  fps: pos_integer(),
  shots: [shot()]
}
```

The `shots` in order, the `canvas` every viewport fits in, in CSS pixels,
the device pixel ratio to render at, and the frame rate.

# `duration_ms`

```elixir
@spec duration_ms(t()) :: non_neg_integer()
```

The video's length in milliseconds.

# `frames`

```elixir
@spec frames(t()) :: non_neg_integer()
```

The number of frames in the video.

# `new`

```elixir
@spec new(
  PhoenixReplay.Recording.t(),
  PhoenixReplay.Recording.PointerTrack.t(),
  keyword()
) :: t()
```

Plans the video of a recording laid out by `PhoenixReplay.Recording.Timeline.for_playback/1`
and its pointer `track`.

## Options

  * `:fps` — frames per second (required)
  * `:idle` — milliseconds a stretch without activity is shortened to,
    or `nil` to keep it whole (required)
  * `:max_dpr` — the highest device pixel ratio to render at (required)
  * `:hold` — milliseconds the last moment is held (required)
  * `:from` and `:to` — the range of the recording to show, in
    milliseconds; `nil` for its first render and its end

---

*Consult [api-reference.md](api-reference.md) for complete listing*
