> ## 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.

# Samsung Tizen and AVPlay

> Keep AVPlay's native video rectangle and the HTML graphics surface in sync.

Place the AVPlay object and graphics inside a positioned stage. Supply `appVideoRect` as the host's full `x`, `y`, `width` and `height` in AVPlay's 1920 × 1080 coordinate system. The adapter updates both the native display rectangle and the HTML object for the L-shaped format.

```js theme={null}
import { attachAvPlay } from '@interactivelayers/player-sdk';
import '@interactivelayers/player-sdk/player.css';

const avplay = webapis.avplay;
const sdk = attachAvPlay({
  avplay,
  stage,
  surface: document.querySelector('object[type="application/avplayer"]'),
  getDisplayRect: () => appVideoRect,
  programTime: () => currentSegment
    ? Math.round(currentSegment.pdtMs + avplay.getCurrentTime() - currentSegment.playerStartMs)
    : null,
  playlistUrl: playback.selectedMediaPlaylistUrl,
});
```

`currentSegment` comes from your integration and describes the segment currently playing, with UTC start in `pdtMs` and its start in the AVPlay timebase in `playerStartMs`. Clear this anchor when the mapping is unknown, including after a discontinuity, and rebuild it from the active segment. The session feed can replace `playlistUrl` by passing `eventsUrl` and `sessionId` with the same clock.

Call `sdk.setLinearAd(true)` and `sdk.setLinearAd(false)` at real linear break boundaries. Call `sdk.destroy()` on teardown and apply the full host rectangle when loading a new medium. On the target Samsung TV, verify video plane stacking, L restoration, clock accuracy after a seek and focus handling. Secondary video in scenes requires a television that can composite a second video surface, and falls back to the poster by default. [Fixture](https://docs.interactivelayers.com/player-sdk.md) · [AVPlay adapter source](https://github.com/InteractiveLayerscom/IL-VideoPlayers-SDK/blob/main/web/README.md#samsung-avplay)

If you link `player.css` from HTML instead of importing it, publish `fonts.css` and the `fonts/` folder with it. See Typeface of the product panels in the [Player SDK](https://docs.interactivelayers.com/player-sdk.md) guide.

With AVPlay, call `sdk.closeProduct()` (or destroy the session) when you open other content, so that an open product panel does not stay over it. See How long the product panel stays in the [Player SDK](https://docs.interactivelayers.com/player-sdk.md) guide.

## IL ads from the plan

`attachAvPlayAds` (`@interactivelayers/player-sdk/avplay-ads`) applies the IL plan on AVPlay: it requests the breaks in order and plays the linear ad (without IMA), draws the Super, the L, the Overlay 300×250 and the product, and shows **Buy** during an iADServer ad. A Tizen app is a packaged app with no HTTPS page of its own, so it loads the plan through the app route. There are two ways to use it. [Which to choose](https://docs.interactivelayers.com/player-sdk.md#native-app-ads)

### The SDK requests the plan

In **Settings → General → My own player**, choose Samsung Tizen AVPlay and register in **Samsung application ID** the id given by `tizen.application.getCurrentApplication().appInfo.id`. `attachAvPlayAppAds` requests `GET https://console.interactivelayers.com/il-player/app-plan?project=…&asset=…&app=tizen:<id>`, without cookies, and never holds the content back waiting for the plan.

```js theme={null}
import { attachAvPlayAppAds } from '@interactivelayers/player-sdk/avplay-ads';

// app: defaults to `tizen:` + tizen.application.getCurrentApplication().appInfo.id
const sdk = await attachAvPlayAppAds({ origin: 'https://console.interactivelayers.com', project, asset,
  avplay: webapis.avplay, session, contentUrl, listener, getDisplayRect, stage, onEvent,
  appParams: { msid, an } });
if (sdk) await sdk.start();   // null: no plan; play without ads
```

* Without a plan, `onEvent` receives `{ type: 'plan_unavailable', app, status, reason }` with the `app` sent and the reason: `http_204` (no plan yet, or a limit was reached), `http_404` (unknown project, video or app: check the registration first), `timeout`, `network`, `invalid`, `app_id`, `request` or `stitched`. No event carries the plan URL or the grant.
* A `version: 2` plan renews itself: the SDK requests it again 20 s before `expires_at` and, if that fails, at 12 and 5 s, with the same shopping session. It emits `plan_renewed`, or `plan_renew_failed` once, after the last attempt. No break starts after expiry (one already playing finishes). If you bring the plan yourself, renew it with `sdk.replacePlan(plan)`.
* With `commerce.break_url` in the plan, the first frame of each iADServer ad with shopping requests the card and draws **Buy**.
* **App identity in Google Ad Manager.** An app's plan has no page. The SDK does not derive `msid` from the Tizen id: the documentation does not say which store id belongs to a Samsung app. Pass `appParams: { msid, an }`; they are added to Google Ad Manager requests when the tag lacks them, never to iADServer.
* A project with server-side insertion gets a plan with `timeline`: AVPlay has no content clock for that case, so `attachAvPlayAppAds` resolves `null` (`reason: 'stitched'`) and the content plays without IL ads.

### The app plays its breaks

If the app 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` (`cuts: []`) to the app. Attach it with `attachAvPlayAds({ plan, planOrigin: 'https://console.interactivelayers.com', … })`. With that plan the SDK plays no ad; the app tells it:

```js theme={null}
sdk.setBreaks([0, 58, 178]);                 // before playback
sdk.breakStarted(58);                        // the break starts; 0 for the pre-roll
sdk.setBreakAd({ tagUrl: answer.ad_tag_url, adId, creativeId });   // or { tagUrl, vastXml } with the playing ad's inline VAST
sdk.clearBreakAd();                          // that ad completed, was skipped or failed
sdk.breakEnded();                            // content is back
```

The duties are the web's: report every break and every ad, do not pass a `sessionId` other than `commerce.session`, and fetch `ad_tag_url` exactly as given. See [Breaks your page plays](https://docs.interactivelayers.com/player-sdk.md#host-breaks-web).

### Network, verification and limits

* **`config.xml`.** Declare the console origin with `<access origin="https://console.interactivelayers.com" subdomains="true"></access>` and the `<tizen:privilege name="http://tizen.org/privilege/internet"/>` privilege.
* **Unconfirmed.** The app route sends no CORS headers, on purpose. It is not confirmed that a packaged Tizen app can read that response: the Samsung documentation consulted does not say, and it was not tested on a TV. If the TV refuses it, `attachAvPlayAppAds` resolves `null` (`reason: 'network'`); then request the plan from your backend and pass it with `attachAvPlayAds({ plan, planOrigin })`. The product URLs have the same condition.
* **What was tested.** Only in Node, with stand-ins for AVPlay. Nothing ran on a TV or a TV emulator, and the Tizen example app was never run.
* The SDK repository includes `examples/api-relay.mjs`, an example backend for the per-break API. **It is only an example: never deploy it.** It gives the power of your API key to anyone who can reach it.

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


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