IMA SDK Plugin for Video.js
The IMA SDK Plugin for Video.js provides a quick and easy IMA SDK integration for the Video.js player.
The framework is currently in beta, allowing interested developers to try it out and send feedback before we finalize the APIs and features.
To see the plugin in action, check out our samples.
- Easily integrate the Google IMA SDK into Video.js to enable advertising on your video content.
- Your favorite text editor
The easiest way to get started is by using npm.
npm install videojs-ima
If you don't use npm, you can download the source from the src/ folder and include it directly in your project. You'll also need to download the source for the videojs-contrib-ads plugin.
<!-- Load dependent stylesheets. --><!-- Load dependent scripts -->
In player.js, load the ads library and set up the IMA plugin:
var player = ;var options =id: 'content_video'adTagUrl: 'YOUR_AD_TAG';// This must be called before player.play() below.player;playerima;// On mobile devices, you must call initializeAdDisplayContainer as the result// of a user action (e.g. button click). If you do not make this call, the SDK// will make it for you, but not as the result of a user action. For more info// see our examples, all of which are set up to work on mobile devices.// player.ima.initializeAdDisplayContainer();// This must be called after player.ima(...) above.player;
That's all there is to it!
The plugin accepts additional settings beyond the two required settings shown in the previous snippet. A summary of all settings follows:
Disable automatic ad break playback
In some circumstances you may want to prevent the SDK from playing ad breaks until you're ready for them. In this scenario, you can disable automatic playback of ad breaks in favor of letting the SDK know when you're ready for an ad break to play. To do so:
autoPlayAdBreaksto false in the initial options.
- Provide an ad break ready listener via
player.ima.playAdBreak()in your ad break ready listener when you're ready to play the ads.
For a list of methods exposed by the plugin, see our full API Docs.
Where do I report issues?
Please report issues on the issues page.
Terms of Service
The IMA SDK plugin for Video.js uses the IMA SDK, and as such is subject to the IMA SDK Terms of Service.
If you have questions about the framework, you can ask them at https://groups.google.com/d/forum/google-media-framework
How do I contribute?
See CONTRIBUTING.md for details.