
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
videojs-ima-player
Advanced tools
[IMA SDK](https://developers.google.com/interactive-media-ads/docs/sdks/html5/v3/apis) integration for video.js. Based on customized videojs player, tech and UI tailored for ad playback.
IMA SDK integration for video.js. Based on customized videojs player, tech and UI tailored for ad playback.
Note: this is not official IMA SDK integration.
npm install videojs-ima-player
<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 order dependent scripts -->
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<script src="/path/to/videojs.v6.0.1.and.later.js"></script>
<script src="/path/to/videojs-contrib-ads.v6.2.0.and.later.js"></script>
<script src="/path/to/videojs.ima.js"></script>
<script>
var player = videojs("content_video");
player.ima({ adTagUrl: "YOUR_AD_TAG" });
</script>
</body>
</html>
If content player's source is changed, it reinitialize IMA SDK and play ads again. To prevent this behaviour (i.e. switching quality),
you have to set player.ads.contentSrc="new-source.mp4" before calling player.src("new-source.mp4").
updateOptions({options}) -- sets new IMA options. This options is applied once content player source is changed.
play() -- call this method to play ad only when autoPlayAdBreaks is set to false and adBreakReady occurs. Otherwise resumes paused ad.
pause() -- pauses current ad.
Usage: player.ima.on(...)/player.ima.off(...)
adTagUrl (string)
url of VMAP/VAST/VPAID resource. REQUIRED IF adsResponse IS NOT PROVIDED.
adsResponse (string)
response in VMAP/VAST/VPAID form. REQUIRED IF adTagUrl IS NOT PROVIDED.
adLabel (string)
Optional translation for text: "Advertisement". Default: "Advertisement"
adsRenderingSettings (Object)
IMA SDK ad rendering settings
autoPlayAdBreaks (boolean)
Autoplay ads. Default: true
contribAdsSettings (Object)
settings for contrib-ads plugin.
debug (boolean)
contrib-ads debug log. Default: false
disableFlashAds (boolean)
Disables flash ads. Default: IMA SDK default
disableCustomPlaybackForIOS10Plus (boolean)
Enables inline playback on iOS 10+. Requires playsinline attribute on video tag. Default: false
forceNonLinearFullSlot (boolean)
Renders non linear ad as linear fullslot. Default: false
locale (string)
Sets locale based on ISO 639-1 (two-letter) or ISO 639-2 (three-letter) code. Default: 'en'
nonLinearWidth (number)
Sets width of non-linear ads. Default: width of content player
nonLinearHeight (number)
Sets height of non-linear ads. Default: 1/3 of content player height
numRedirects (number)
Maximum number of VAST redirects. Default: IMA SDK default
ofLabel (string)
Optional translation for text "of" (e.g. "1 of 2"). Default: of"
showControlsForJSAds (boolean)
Enables controls for VPAID JavaScript ads. Default: true
showCountdown (boolean)
Enables countdown timer. Default: true
timeout (number)
contrib-ads hard timeout for loading preroll/postroll ads. Default: 5000
vpaidMode (VpaidMode)
google.ima.ImaSdkSettings.VpaidMode. Default: ENABLED
forceSkipTime (number)
If non-skippable or value is lower than linear's skipOffset, use custom skip button from provided timestamp (seconds). Default: undefined
forceSkipLabel (string)
Optional translation for text "Skip Ad", Default: "Skip Ad"
Timing of ad playback is handled by IMA SDK. If autoplayAdBreaks is set to false, this feature is turned off and is up to you when you play the ad (once adBreakReady is triggered).
autoPlayAdBreaks to falseplayer.ima.on('adBreakReady', player.ima.play)This integration use hard timeout 5s. If ad is not loaded within given time,
IMA silently skips current ad and resumes content playback. You can adjust this
timeout by timeout setting. As IMA SDK supports only one timeout value,
different preroll/postroll timeouts are not supported in this plugin.
Default: timeout = 5000, adsRenderingSettings.loadVideoTimeout = timeout.
FAQs
[IMA SDK](https://developers.google.com/interactive-media-ads/docs/sdks/html5/v3/apis) integration for video.js. Based on customized videojs player, tech and UI tailored for ad playback.
The npm package videojs-ima-player receives a total of 1,483 weekly downloads. As such, videojs-ima-player popularity was classified as popular.
We found that videojs-ima-player demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.