> ## Documentation Index
> Fetch the complete documentation index at: https://docs.interactivelayers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Roku SceneGraph

> Connect the ILOverlay component to the app's Video node.

Copy `roku/components/ILOverlay` into your app's `components/` directory. Mount it next to the existing `Video` node and place controls above the graphics. Use a fresh session ID for new content.

```brightscript theme={null}
m.ilSession = playback.sessionId
m.il = m.video.getParent().createChild("ILOverlay")
m.il.observeFieldScoped("impression", "onOverlayImpression")
m.il.callFunc("attach", m.video, m.ilSession)

' After fetching the selected media playlist:
m.il.callFunc("setManifest", m.ilSession, playlistText)
' Or pass the JSON session array to setTimeline.
```

`setManifest` accepts a full media playlist. Keep it in sync with ABR variant changes. Alternatively pass the complete session array using `setTimeline`. An empty array withdraws the cues. For JSON on Roku OS 14.6+, use `parseJson(body, "d")` to preserve UNIX milliseconds. On older versions preserve those values explicitly as `LongInteger` or `Double`.

The component uses `Video.positionInfo` for the last rendered frame. With `epoch=0`, supply `setClockAnchor` with verified clip ID and the mapping of program time to video position. Update `linearBreak` from actual break boundaries and `seeking` during app-controlled seeks. Forward the component's `impression` event once through your measurement transport. Call `detach` before removing the node.

Run `sh roku/verify.sh` for parser, layout and timing tests. On the target Roku, verify HTTPS artwork, native video geometry, playback position after seeks and impression delivery. [Cue fixture](https://docs.interactivelayers.com/player-sdk.md) · [Roku API details and examples](https://github.com/InteractiveLayerscom/IL-VideoPlayers-SDK/blob/main/roku/README.md)

## IL ads from the plan

`ILAdPlanPlayer` reads the IL plan and plays the breaks with the Roku Advertising Framework (RAF), draws the Super, the L and the product, and shows **Buy** during an iADServer ad. The channel needs `bs_libs_required=roku_ads_lib` in its manifest. There are two ways to use it. [Which to choose](https://docs.interactivelayers.com/player-sdk.md#native-app-ads)

### The component requests the plan

In **Settings → General → My own player**, choose Roku SceneGraph and register in **Roku channel ID** the channel id: the one from `roAppInfo.GetID()` for a published channel, or `dev` for one installed in developer mode. The component requests `GET https://console.interactivelayers.com/il-player/app-plan?project=…&asset=…&app=roku:<id>` with a 5-second limit. Start the content when `contentReady` is true.

```brightscript theme={null}
m.il.callFunc("attach", m.video, m.viewId)
m.plan = m.video.getParent().createChild("ILAdPlanPlayer")
m.plan.observeFieldScoped("contentReady", "onContentReady")
m.plan.observeFieldScoped("event", "onPlanEvent")
m.plan.callFunc("loadPlan", m.il, m.video, m.viewId, "https://console.interactivelayers.com", projectId, assetId, "en", consent)
```

* On `204`, a `404`, a network error or a timeout, the content starts without ads. The `{ type: "plan_unavailable", status, app, reason }` event carries the `app=` that was sent: a `404` is the same answer for an unknown project, video or app, so check the registration first.
* With `loadPlan`, the iADServer session is the plan's `commerce.session`; `m.viewId` only identifies the view in the overlay.
* A `version: 2` plan expires after 120 s. The component requests it again up to three times, 20, 12 and 5 s before `expires_at`, and keeps what was already shown, the pacing and the shopping session. It emits `plan_renewed`, or `plan_renew_failed` once, after the last failed attempt; on expiry, `plan_expired`, and the content continues. If you get the plan yourself, renew it with `replacePlan`.
* Consent (`gdpr`, `gdpr_consent`, `us_privacy`, `gpp`, `gpp_sid`) goes as the last argument, because Roku has no standard store.
* With `commerce.break_url` in the plan, the component requests the product during an iADServer ad and draws **Buy** until the ad ends. It takes the identity from the RAF ad's `adId` field or, when that is missing, from the iADServer impression URL.

### The channel plays its breaks

If the channel requests its breaks from the [per-break API](https://docs.interactivelayers.com/vod-operations.md#app-break-graphics), your backend creates the playback with `"graphics": true` and passes `GET /v1/vod/playbacks/{id}/plan` to the channel. The component neither requests nor plays ads; the channel reports its breaks:

```brightscript theme={null}
key = plan.commerce.session                        ' the plan's session: without it there is no Buy
m.il.callFunc("attach", m.video, key)
m.plan.callFunc("attachPlan", m.il, m.video, key, plan, "https://console.interactivelayers.com", "en", consent)
m.plan.callFunc("setBreaks", [58000, 178000])      ' content positions in ms
m.plan.callFunc("startPlan")

m.plan.callFunc("breakStarted", 58000)             ' 0 for the pre-roll
m.plan.callFunc("adStarted", adTagUrl, ctx.ad)     ' on the RAF "Impression" event; adTagUrl = the ad_tag_url you fetched
m.plan.callFunc("adEnded")                         ' on "Complete", "Skip", "Close" or "Error"
m.plan.callFunc("breakEnded")                      ' back to content
```

* **Report the breaks before they arrive.** The component applies `scenes.pacing.cut_clearance_seconds` around each position reported with `setBreaks` or, failing that, with `breakStarted`. With no reported breaks there is no clearance, and the component can draw over a break the channel did not announce.
* **Attach with `plan.commerce.session`**, in `attach` and in `attachPlan`. With another key the component emits `{ type: "buy_unavailable", reason: "session" }` once and shows no **Buy** during breaks.
* **Fetch `ad_tag_url` exactly as given**, without touching `sid` or `correlator`.
* If the channel does not call `breakEnded`, after 130 seconds the component ends the break, emits `break_error` and draws again. Do not rely on this.
* During a reported break nothing from IL is drawn except **Buy**, and the component never touches the `Video` node's visibility or playback.

### Limits and verification

* The **Overlay 300×250** is not available on Roku: Google offers neither GPT nor its display SDK for Roku.
* Roku's ADS 1.1 requirement covers banners that are not Roku's, such as the Super, the L and the product. Before publishing, declare the SDK to Roku; Roku may reject it.
* The component does not add `msid`, `an`, `url` or `description_url` to Google Ad Manager requests. If your agreement with Google requires the channel identity, the project's tags must already carry it.
* The **Buy** panel during an ad closes when the ad ends.
* A project with server-side insertion gets a plan the component refuses (`reason: "stitched"`): the channel plays without IL ads.
* Everything was tested in the desktop interpreter, with a network double and a frozen clock. Real RAF, HLS playback, HTTPS download and on-screen composition were not tested on a Roku; neither way of reading the ad identity for **Buy** has run on a device.

[Ad plan on Roku](https://github.com/InteractiveLayerscom/IL-VideoPlayers-SDK/blob/main/roku/README.md#plan-de-anuncios)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.