# Instream Player

Nexx360 Instream Player is a lightweight JavaScript library that provides instream video ad playback powered by Nexx360's server-side auction. It sends OpenRTB 2.5 bid requests, receives VAST creatives, and plays them via the Google IMA SDK — all with a simple two-method API.

## Key Benefits

* **Server-side Auction**: OpenRTB bid requests are sent to Nexx360's auction endpoint, running competition across multiple SSPs server-side
* **Viewport Auto-play**: Ads automatically play when the container scrolls into view and pause when it leaves
* **Google IMA SDK**: Industry-standard video ad playback with full VAST/VPAID support
* **Lightweight**: Single script with no dependencies beyond the IMA SDK (loaded on demand)
* **Privacy Compliant**: Built-in support for GDPR/TCF and US Privacy (CCPA)
* **Event-driven**: Rich event system for tracking ad lifecycle (loaded, started, quartiles, complete, etc.)

## How It Works

1. You call `init()` with your `tagId` and a container element
2. When the container enters the viewport, the library:
   * Loads the Google IMA SDK
   * Sends an OpenRTB bid request to `https://fast.nexx360.io/ortb-lib`
   * If a bid with VAST XML is returned, plays it via IMA
3. The ad pauses when scrolled out of view and resumes when scrolled back in
4. After the ad completes, the player cleans itself up

## Quick Start

```html
<!-- 1. Add a container element -->
<div id="video-ad" style="width: 640px; height: 480px;"></div>

<!-- 2. Load the instream player -->
<script src="https://lib.nexx360.io/nexx360instream/api.js"></script>

<!-- 3. Initialize -->
<script>
  // Listen to events (optional)
  nexx360InstreamPlayer.on('started', function() {
    console.log('Ad started playing');
  });

  nexx360InstreamPlayer.on('complete', function() {
    console.log('Ad finished');
  });

  nexx360InstreamPlayer.on('error', function(data) {
    console.error('Ad error:', data);
  });

  // Initialize — ad will auto-play when container enters viewport
  nexx360InstreamPlayer.init({
    tagId: 'your-tag-id',
    container: 'video-ad'
  });
</script>
```

{% hint style="info" %}
The `tagId` is configured in the [Nexx360 console](https://console.nexx360.io). See [Add and manage tagIds](/general-configuration/add-and-manage-tagids.md) for setup instructions.
{% endhint %}

## Next Steps

* [API Reference](/integration-methods/instream-player/api-reference.md) — Complete API documentation with all configuration options
* [Privacy & Consent](/integration-methods/instream-player/privacy-consent.md) — GDPR/TCF and US Privacy configuration


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.nexx360.io/integration-methods/instream-player.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
