The latest version of the IMA Plugin for Video.js includes support for DAI ads.
The example above demonstrates a VOD stream with DAI integration for server-side ad insertion using a videojs player with the Nuevo and Ima plugins.
<script src="//imasdk.googleapis.com/js/sdkloader/ima3_dai.js"></script> <script src="/videojs/video.min.js"></script> <script src="/videojs/nuevo.min.js"></script> <script src="/videojs/plugins/videojs-contrib-ads.js"></script> <script src="/videojs/plugins/videojs.ima.js"></script> <video id="myplayer" class="video-js" poster="//domain.com/path/to/poster.jpg" controls preload="auto"> </video> <script> player = videojs('video_player', videoOptions); player.nuevo(nuevoOptions); var stream = new window.videojsIma.VodStream("hls", "2528370", "tears-of-steel" ); var imaOptions = { fallbackStreamUrl: 'http://storage.googleapis.com/testtopbox-public/video_content/bbb/master.m3u8', // Include other IMA DAI options as needed. } player.imaDai(vodStream, imaOptions); </script>
var stream = new window.videojsIma.LiveStream("hls", "sN_IYUG8STe1ZzhIIE_ksA" );
npm install videojs-contrib-ads npm install videojs-ima
import videojs from 'video.js'; import "./videojs/plugins/es/nuevo"; import 'videojs-contrib-hls'; import 'videojs-ima'; import {VodStream, LiveStream} from 'videojs-ima'; const videoOptions = { controls: true, // Include other video.js options as needed. }; const player = videojs('video_player', videoOptions); const nuevoOptions = { contextMenu: false, // Include other Nuevo options as needed. }; player.nuevo(); // Example of a VOD stream using IMA's sample stream. const vodStream = new VodStream('hls', '2528370', 'tears-of-steel'); // Example of a Live stream using IMA's sample stream. const liveStream = new LiveStream('hls', 'sN_IYUG8STe1ZzhIIE_ksA'); const imaOptions = { fallbackStreamUrl: 'http://storage.googleapis.com/testtopbox-public/video_content/bbb/master.m3u8', // Include other IMA DAI options as needed. }; player.imaDai(vodStream, imaOptions);