
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
videojs-ima
Advanced tools
[](https://travis-ci.org/googleads/videojs-ima) [ javascript file:
<html>
<head>
<!-- Load dependent stylesheets. -->
<link href="path/to/video-js.css" rel="stylesheet">
<link rel="stylesheet" href="path/to/videojs-contrib-ads.css" />
<link rel="stylesheet" href="path/to/videojs.ima.css" />
</head>
<body>
<video id="content_video" class="video-js vjs-default-skin"
controls preload="auto" width="YOUR_VIDEO_WIDTH" height="YOUR_VIDEO_HEIGHT">
<source src="PATH_TO_YOUR_CONTENT_VIDEO" type="YOUR_CONTENT_VIDEO_TYPE" />
</video>
<!-- Load dependent scripts -->
<script src="/path/to/video.js"></script>
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<script src="/path/to/videojs-contrib-ads.js"></script>
<script src="/path/to/videojs.ima.js"></script>
<script src="player.js"></script>
</body>
</html>
In player.js, load the ads library and set up the IMA plugin:
var player = videojs('content_video');
var options = {
id: 'content_video',
adTagUrl: 'YOUR_AD_TAG'
};
player.ima(options);
// 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();
That's all there is to it!
Check out the snippet above in-action on CodePen.
The plugin accepts additional settings beyond the two required settings shown in the previous snippet. A summary of all settings follows:
Settings | Type | Description |
---|---|---|
id | string | REQUIRED The id of your video player |
adTagUrl | string | REQUIRED IF adsResponse IS NOT PROVIDED A URL which returns a VAST, VMAP or ad rules,response. |
adsResponse | string | REQUIRED IF adTagUrl IS NOT PROVIDED The VAST, VMAP, or ad rules response to use,in lieu of fetching one an ad tag. |
adLabel | string | Replaces the "Advertisement" text in the ad label. Added for multilingual UI support. |
adLabelNofN | string | Replaces the "of" text in the ad label (e.g. ... (1 of 2) ...). Added for multilingual UI support. |
adsRenderingSettings | object | JSON object with ads rendering settings as defined in the IMA SDK,Docs(1). |
autoPlayAdBreaks | boolean | Whether or not to automatically play VMAP or ad rules ad breaks. Defaults,to true. |
deprecated adWillPlayMuted | boolean | Notifies the SDK whether the player intends to start ad while muted. Changing this setting will have no impact on ad playback. Defaults,to false. |
contribAdsSettings | object | Additional settings to be passed to the contrib-ads plugin(2), used by,this IMA plugin. |
debug | boolean | True to load the debug version of the plugin, false to load the non-debug version.,Defaults to false. |
disableFlashAds | boolean | True to disable Flash ads - Flash ads will be considered an unsupported ad type. Defaults to false. |
disableCustomPlaybackForIOS10Plus | boolean | Sets whether to disable custom playback on iOS 10+ browsers. If true, ads will play inline if the content video is inline. Defaults to false. |
forceNonLinearFullSlot | boolean | True to force non-linear AdSense ads to render as linear fullslot.,If set, the content video will be paused and the non-linear text or image ad will be rendered as,fullslot. The content video will resume once the ad has been skipped or closed. |
locale | string | Locale for ad localization. This may be any,ISO 639-1 (two-letter) or ISO 639-2,(three-letter) code(3). Defaults to 'en'. |
nonLinearWidth | number | Desired width of non-linear ads. Defaults to player width. |
nonLinearHeight | number | Desired height for non-linear ads. Defaults to 1/3 player height. |
numRedirects | number | Maximum number of VAST redirects before the subsequent redirects will be denied,,and the ad load aborted. The number of redirects directly affects latency and thus user experience.,This applies to all VAST wrapper ads. |
showControlsForJSAds | boolean | Whether or not to show the control bar for VPAID JavaScript ads. Defaults to true. |
showCountdown | boolean | Whether or not to show the ad countdown timer. Defaults to true. |
vastLoadTimeout | number | Override for default VAST load timeout in milliseconds for a single wrapper. The default timeout is 5000ms. |
vpaidAllowed | boolean | (DEPRECATED, please use vpaidMode). |
vpaidMode | VpaidMode(4) | VPAID Mode. Defaults to ENABLED. This setting,overrides vpaidAllowed. |
(1) IMA SDK Docs
(2) contrib-ads plugin
(3) Valid locale codes
(4) google.ima.ImaSdkSettings.VpaidMode
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:
autoPlayAdBreaks
to false in the initial options.setAdBreakReadyListener
.player.ima.playAdBreak()
in your ad break ready listener when
you're ready to play the ads.Please report issues on the issues page.
The IMA SDK plugin for Video.js uses the IMA SDK, and as such is subject to the IMA SDK Terms of Service.
See CONTRIBUTING.md for details.
FAQs
[](https://travis-ci.org/googleads/videojs-ima)
The npm package videojs-ima receives a total of 17,015 weekly downloads. As such, videojs-ima popularity was classified as popular.
We found that videojs-ima demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.