# Video Integration with VAST The Adhese VAST JS library is designed to make it easy to integrate VAST ads into video players. It includes cross-domain safe methods for requesting ads from your Adhese account and convenient methods for playing and tracking video ads. However, it is not a player on its own and does not insert anything into the DOM. 1. Load the JavaScript file: ```javascript ``` 2. Create an `AdheseVastWrapper` object: ```javascript var wrapper = newAdheseVastWrapper(); ``` 3. Register a listener for the ADS\_LOADED event fired by `AdheseVastWrapper` The first parameter is the event name, and the second is the name of your callback function. This function will be called when the wrapper is ready to handle your ad request. ```javascript wrapper.addEventListener("ADS_LOADED", yourCallBackFunction); ``` 4. Initiate an ad request by providing the host of your Adhese account and the slot path and target parameters you want to request. ```javascript wrapper.requestAds("http://ads.demo.adhese.com", "_test_", ["preroll", "postroll"]); ``` 5. Once the request is finished, `AdheseVastWrapper` will fire the ADS\_LOADED event, and your callback function will be called. From then on, you can access several properties of the wrapper object to get info on the ads. This is a complete example: ```html

``` ## Ad Pods (VAST & JSON) ### About Ad Pods An Ad Pod is a sequenced group of ads that allows publishers to display multiple ads within a single ad placement. In the case of VAST, the ads can play before, during, or after the video content. In this case, ad pods are very similar to TV commercial breaks. Pods are populated by [Advar templates](https://documentation.adhese.org/books/templating/page/advar-templates). We support two formats: VAST XML and JSON. ### Request Fill in the necessary brackets in the following ad pod request URL and paste it into your VAST-supporting video player. ``` https://ads-[client].adhese.com/m/[adpod type]/sl[position identification]/[targeting]/?max_ads=[max number of desired ads]&t=[timestamp] ``` - adpod type — **adpod** for VAST, **stack** for JSON. - max\_ads — the returned number of ads will depend on different parameters, like availability and targeting, but will never exceed max\_ads. ### Output **VAST** ``` `(in the template) will sort the ads in a pod by creative ID. #### Templates **VAST** ``` VAST ad implementation ``` **JSON** ``` { "sequence": 0, "example field": "some value" } ```

The sequence field must be added to the **main structure** of the JSON template. The order logic will not work if the field is added to a nested object within the JSON template. The field will be **stripped from the response** when the Adpod or Stack response is rendered.