IMA SDK Plugin for Clappr.
npm install clappr-ima-plugin 
Google IMA HTML5 SDK ads plugin for Clappr video player.
To see the plugin in action, check out demo page.
Add both Clappr and the plugin scripts to your HTML :
``html`
Then add ClapprImaPlugin into the list of plugins of your player instance, and the options for the plugin go in the imaPlugin property as shown below :
`javascript`
var player = new Clappr.Player({
source: "https://your.video/here.mp4",
playback: {
playInline: true, // Required by skippable ads on iOS (not fullscreen)
},
plugins: [
ClapprImaPlugin
],
imaPlugin: {
// requestAdIfNoAutoplay: true,
// disableNonLinear: true,
// disableNonLinearForIOS: true,
// resetAdOnEnded: true,
// onAdPlayerReady: function (adPlayer) { adPlayer.on('midpoint', function(o) { console.log(o); }); },
imaAdPlayer: {
tag: 'https://myadserver.com/path/to/vast/tag.xml',
// vpaidMode: ClapprImaPlugin.vpaidMode.INSECURE,
// locale: 'fr',
// maxDuration: 30000,
// nonLinearMaxDuration: 8000,
// adsRenderingOptions: {
// useStyledNonLinearAds: true,
// },
},
},
});
Skippable ads require that your video player play content inline (not fullscreen) on iPhone.
| Name | Type | Required | Description |
| --- | :---: | :---: | --- |
| imaAdPlayer | object | __yes__ | The IMA Ad player configuration object. _(must at least contain "tag" property)_ |
| disableNonLinear | boolean | no | Set this option to true to not display non-linear ads (default is false) |true
| disableNonLinearForIOS | boolean | no | Set this option to to not display non-linear ads on iOS devices. There is a known issue with non-linear ads and "click_to_play" Clappr internal plugin on iOS devices. (default is false) |true
| onAdPlayerReady | Function | no | Can be used to retrieve IMA Ad Player instance. For example, to bind specific ad player events. |
| requestAdIfNoAutoplay | boolean | no | Set this option to to attempt to pre-request ads if autoplay is not allowed by browser. By default, ads are requested when video content is started. (default is false) |true
| resetAdOnEnded | boolean | no | Set this option to to reset ads scenario when content video is ended. By default, ads are not displayed again if video content is restarted. (default is false) |
Install dependencies :
`shell`
yarn
Start HTTP dev server (http://0.0.0.0:8080) :
`shell``
npm start
The MIT License (MIT). Please see License File for more information.