Overview
This guide will walk you through creating a basic ad player that fetches a VAST tag and plays a video advertisement on Smart TV platforms.Time to complete: ~5 minutesWhat you’ll build: A fully functional video ad player with autoplay, skip button, progress tracking, and event handling
Prerequisites
Before starting, ensure you have:- Node.js 14+ installed
- A Smart TV project (or any JavaScript/TypeScript project)
- A VAST tag URL for testing (you can use a test VAST from your ad server)
Step-by-Step Guide
Initialize and play the ad
Call
init() to fetch the VAST and prepare the player, then call play() to start playback:The
init() method automatically attempts autoplay using the “Nuclear Mute” strategy (muted + playsinline + autoplay). If autoplay fails (rare on TVs), an interactive overlay will appear.Complete Example
Here’s a complete working example:What Happens Under the Hood
When you callsdk.init(), Adgent SDK performs the following steps:
Parse and resolve wrappers
Parses the XML and follows wrapper chains up to 5 levels deep, aggregating tracking pixels
Select best media file
Analyzes available media files and selects the optimal one based on:
- Codec compatibility (H.264 > H.265 > VP9)
- Bitrate matching (closest to
targetBitrate: 2500kbps) - Resolution preference (1080p preferred, 4K penalized)
- Container format (MP4 preferred)
Create video element
Generates an HTML5
<video> element with platform-specific attributes:muted(for autoplay compliance)playsinline(for iOS/mobile platforms)autoplay(attempts immediate playback)crossorigin="anonymous"(for CDN content)
Setup UI components
Creates:
- Skip button (appears after
skipOffsetseconds) - Progress indicator (top-left “Ad • 1 of 1 • 0:30” counter)
- Focus trap (captures remote control keys)
The “Nuclear Mute” strategy (muted + playsinline + autoplay) achieves near-100% autoplay success on Smart TV platforms, with the interactive overlay as a graceful fallback.
Testing Your Integration
Use this test VAST URL for development:Common Issues
Ad doesn't autoplay
Ad doesn't autoplay
Solution: This is expected behavior on some platforms. The SDK automatically shows an interactive overlay when autoplay fails. Ensure your container is visible and the user can interact with it.
Video doesn't fit the container
Video doesn't fit the container
Solution: Ensure your container has explicit
width and height styles and position: relative:Error: No suitable media file found
Error: No suitable media file found
Solution: The VAST tag may contain only VPAID or unsupported formats. Adgent SDK filters out VPAID and selects H.264/VP9 video files. Verify your VAST contains standard MP4 media files.
Skip button doesn't appear
Skip button doesn't appear
Next Steps
Now that you have a working ad player, explore these advanced features:Event Handling
Learn about all available events and callbacks
Configuration Options
Customize bitrate, timeouts, skip behavior, and more
Platform Adapters
Platform-specific features for WebOS, Tizen, and Vidaa
API Reference
Complete API documentation
