videojs-ima
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -0,1 +1,9 @@ | ||
<a name="1.0.4"></a> | ||
## [1.0.4](https://github.com/googleads/videojs-ima/compare/v1.0.3...v1.0.4) (2018-01-17) | ||
### Documentation | ||
* Add keywords to package.json. This should list us on the videoj… ([#486](https://github.com/googleads/videojs-ima/issues/486)) ([7af46cf](https://github.com/googleads/videojs-ima/commit/7af46cf)) | ||
* Update README with new snippet and codepen link. ([#483](https://github.com/googleads/videojs-ima/issues/483)) ([2d40f74](https://github.com/googleads/videojs-ima/commit/2d40f74)) | ||
<a name="1.0.3"></a> | ||
@@ -2,0 +10,0 @@ ## [1.0.3](https://github.com/googleads/videojs-ima/compare/v1.0.2...v1.0.3) (2018-01-03) |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],e):e(t.videojs)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e=function(t,e,i){this.vjsPlayer=t,this.controller=i,this.contentTrackingTimer=null,this.contentComplete=!1,this.updateTimeIntervalHandle=null,this.updateTimeInterval=1e3,this.seekCheckIntervalHandle=null,this.seekCheckInterval=1e3,this.resizeCheckIntervalHandle=null,this.resizeCheckInterval=250,this.seekThreshold=100,this.contentEndedListeners=[],this.contentSource="",this.contentPlayheadTracker={currentTime:0,previousTime:0,seeking:!1,duration:0},this.vjsPlayerDimensions={width:this.getPlayerWidth(),height:this.getPlayerHeight()},this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=document.getElementById(this.controller.getSettings().id).getElementsByClassName("vjs-tech")[0],this.h5Player.hasAttribute("autoplay")&&this.controller.setSetting("adWillAutoPlay",!0),this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this)),this.boundContentEndedListener=this.localContentEndedListener.bind(this),this.vjsPlayer.on("ended",this.boundContentEndedListener),this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("readyforpreroll",this.onReadyForPreroll.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),this.vjsPlayer.ads(e)};e.prototype.setUpPlayerIntervals=function(){this.updateTimeIntervalHandle=setInterval(this.updateCurrentTime.bind(this),this.updateTimeInterval),this.seekCheckIntervalHandle=setInterval(this.checkForSeeking.bind(this),this.seekCheckInterval),this.resizeCheckIntervalHandle=setInterval(this.checkForResize.bind(this),this.resizeCheckInterval)},e.prototype.updateCurrentTime=function(){this.contentPlayheadTracker.seeking||(this.contentPlayheadTracker.currentTime=this.vjsPlayer.currentTime())},e.prototype.checkForSeeking=function(){var t=1e3*(this.vjsPlayer.currentTime()-this.contentPlayheadTracker.previousTime);Math.abs(t)>this.seekCheckInterval+this.seekThreshold?this.contentPlayheadTracker.seeking=!0:this.contentPlayheadTracker.seeking=!1,this.contentPlayheadTracker.previousTime=this.vjsPlayer.currentTime()},e.prototype.checkForResize=function(){var t=this.getPlayerWidth(),e=this.getPlayerHeight();t==this.vjsPlayerDimensions.width&&e==this.vjsPlayerDimensions.height||(this.vjsPlayerDimensions.width=t,this.vjsPlayerDimensions.height=e,this.controller.onPlayerResize())},e.prototype.localContentEndedListener=function(){this.contentComplete||(this.contentComplete=!0,this.controller.onContentComplete());for(var t in this.contentEndedListeners)"function"==typeof this.contentEndedListeners[t]&&this.contentEndedListeners[t]();clearInterval(this.updateTimeIntervalHandle),clearInterval(this.seekCheckIntervalHandle),clearInterval(this.resizeCheckIntervalHandle),this.vjsPlayer.el()&&this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this))},e.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.controller.onPlayerDisposed(),this.contentComplete=!0,this.vjsPlayer.off("ended",this.localContentEndedListener),this.vjsPlayer.ads.adTimeoutTimeout&&clearTimeout(this.vjsPlayer.ads.adTimeoutTimeout);var t=[this.updateTimeIntervalHandle,this.seekCheckIntervalHandle,this.resizeCheckIntervalHandle];for(var e in t)t[e]&&clearInterval(t[e])},e.prototype.onReadyForPreroll=function(){this.controller.onPlayerReadyForPreroll()},e.prototype.onPlayerReady=function(){this.onVolumeChange(),this.vjsPlayer.on("fullscreenchange",this.onFullscreenChange.bind(this)),this.vjsPlayer.on("volumechange",this.onVolumeChange.bind(this))},e.prototype.onFullscreenChange=function(){this.vjsPlayer.isFullscreen()?this.controller.onPlayerEnterFullscreen():this.controller.onPlayerExitFullscreen()},e.prototype.onVolumeChange=function(){var t=this.vjsPlayer.muted()?0:this.vjsPlayer.volume();this.controller.onPlayerVolumeChanged(t)},e.prototype.injectAdContainerDiv=function(t){this.vjsControls.el().parentNode.appendChild(t)},e.prototype.getContentPlayer=function(){return this.h5Player},e.prototype.getVolume=function(){return this.vjsPlayer.muted()?0:this.vjsPlayer.volume()},e.prototype.setVolume=function(t){this.vjsPlayer.volume(t),0==t?this.vjsPlayer.muted(!0):this.vjsPlayer.muted(!1)},e.prototype.unmute=function(){this.vjsPlayer.muted(!1)},e.prototype.mute=function(){this.vjsPlayer.muted(!0)},e.prototype.play=function(){this.vjsPlayer.play()},e.prototype.getPlayerWidth=function(){var t=this.vjsPlayer.el().getBoundingClientRect()||{};return parseInt(t.width,10)||this.vjsPlayer.width()},e.prototype.getPlayerHeight=function(){var t=this.vjsPlayer.el().getBoundingClientRect()||{};return parseInt(t.height,10)||this.vjsPlayer.height()},e.prototype.toggleFullscreen=function(){this.vjsPlayer.isFullscreen()?this.vjsPlayer.exitFullscreen():this.vjsPlayer.requestFullscreen()},e.prototype.getContentPlayheadTracker=function(){return this.contentPlayheadTracker},e.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},e.prototype.onAdBreakStart=function(t){this.contentSource=this.vjsPlayer.currentSrc(),this.vjsPlayer.off("ended",this.boundContentEndedListener),-1!=t.getAd().getAdPodInfo().getPodIndex()&&this.vjsPlayer.ads.startLinearAdMode(),this.vjsControls.hide(),this.vjsPlayer.pause()},e.prototype.onAdBreakEnd=function(){this.vjsPlayer.on("ended",this.boundContentEndedListener),this.vjsPlayer.ads.endLinearAdMode(),this.vjsControls.show()},e.prototype.onAdStart=function(){this.vjsPlayer.trigger("ads-ad-started")},e.prototype.onAllAdsCompleted=function(){1==this.contentComplete&&(this.h5Player.src!=this.contentSource&&this.vjsPlayer.src(this.contentSource),this.controller.onContentAndAdsCompleted())},e.prototype.onAdsReady=function(){this.vjsPlayer.trigger("adsready")},e.prototype.changeSource=function(t,e){this.vjsPlayer.currentSrc()&&(this.vjsPlayer.currentTime(0),this.vjsPlayer.pause()),t&&this.vjsPlayer.src(t),e?this.vjsPlayer.one("loadedmetadata",this.playContentFromZero.bind(this)):this.vjsPlayer.one("loadedmetadata",this.seekContentToZero.bind(this))},e.prototype.seekContentToZero=function(){this.vjsPlayer.currentTime(0)},e.prototype.playContentFromZero=function(){this.vjsPlayer.currentTime(0),this.vjsPlayer.play()},e.prototype.addContentEndedListener=function(t){this.contentEndedListeners.push(t)},e.prototype.reset=function(){this.vjsPlayer.on("ended",this.boundContentEndedListener),this.vjsControls.show(),this.vjsPlayer.ads.endLinearAdMode(),this.contentPlayheadTracker.currentTime=0};var i=function(t){this.controller=t,this.adContainerDiv=document.createElement("div"),this.controlsDiv=document.createElement("div"),this.countdownDiv=document.createElement("div"),this.seekBarDiv=document.createElement("div"),this.progressDiv=document.createElement("div"),this.playPauseDiv=document.createElement("div"),this.muteDiv=document.createElement("div"),this.sliderDiv=document.createElement("div"),this.sliderLevelDiv=document.createElement("div"),this.fullscreenDiv=document.createElement("div"),this.boundOnMouseUp=this.onMouseUp.bind(this),this.boundOnMouseUp=this.onMouseMove.bind(this),this.adPlayheadTracker={currentTime:0,duration:0,isPod:!1,adPosition:0,totalAds:0},this.controlPrefix=this.controller.getSettings().id?this.controller.getSettings().id+"_":"",this.showCountdown=!0,!1===this.controller.getSettings().showCountdown&&(this.showCountdown=!1),this.createAdContainer()};i.prototype.createAdContainer=function(){this.assignControlAttributes(this.adContainerDiv,"ima-ad-container"),this.adContainerDiv.style.position="absolute",this.adContainerDiv.style.zIndex=1111,this.adContainerDiv.addEventListener("mouseenter",this.showAdControls.bind(this),!1),this.adContainerDiv.addEventListener("mouseleave",this.hideAdControls.bind(this),!1),this.createControls(),this.controller.injectAdContainerDiv(this.adContainerDiv)},i.prototype.createControls=function(){this.assignControlAttributes(this.controlsDiv,"ima-controls-div"),this.controlsDiv.style.width="100%",this.assignControlAttributes(this.countdownDiv,"ima-countdown-div"),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel,this.countdownDiv.style.display=this.showCountdown?"block":"none",this.assignControlAttributes(this.seekBarDiv,"ima-seek-bar-div"),this.seekBarDiv.style.width="100%",this.assignControlAttributes(this.progressDiv,"ima-progress-div"),this.assignControlAttributes(this.playPauseDiv,"ima-play-pause-div"),this.addClass(this.playPauseDiv,"ima-playing"),this.playPauseDiv.addEventListener("click",this.onAdPlayPauseClick.bind(this),!1),this.assignControlAttributes(this.muteDiv,"ima-mute-div"),this.addClass(this.muteDiv,"ima-non-muted"),this.muteDiv.addEventListener("click",this.onAdMuteClick.bind(this),!1),this.assignControlAttributes(this.sliderDiv,"ima-slider-div"),this.sliderDiv.addEventListener("mousedown",this.onAdVolumeSliderMouseDown.bind(this),!1),this.assignControlAttributes(this.sliderLevelDiv,"ima-slider-level-div"),this.assignControlAttributes(this.fullscreenDiv,"ima-fullscreen-div"),this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.fullscreenDiv.addEventListener("click",this.onAdFullscreenClick.bind(this),!1),this.adContainerDiv.appendChild(this.controlsDiv),this.controlsDiv.appendChild(this.countdownDiv),this.controlsDiv.appendChild(this.seekBarDiv),this.controlsDiv.appendChild(this.playPauseDiv),this.controlsDiv.appendChild(this.muteDiv),this.controlsDiv.appendChild(this.sliderDiv),this.controlsDiv.appendChild(this.fullscreenDiv),this.seekBarDiv.appendChild(this.progressDiv),this.sliderDiv.appendChild(this.sliderLevelDiv)},i.prototype.onAdPlayPauseClick=function(){this.controller.onAdPlayPauseClick()},i.prototype.onAdMuteClick=function(){this.controller.onAdMuteClick()},i.prototype.onAdFullscreenClick=function(){this.controller.toggleFullscreen()},i.prototype.onAdsPaused=function(){this.addClass(this.playPauseDiv,"ima-paused"),this.removeClass(this.playPauseDiv,"ima-playing"),this.showAdControls()},i.prototype.onAdsResumed=function(){this.onAdsPlaying(),this.showAdControls()},i.prototype.onAdsPlaying=function(){this.addClass(this.playPauseDiv,"ima-playing"),this.removeClass(this.playPauseDiv,"ima-paused")},i.prototype.updateAdUi=function(t,e,i,n){var s=e-t,o=Math.floor(s/60),r=Math.floor(s%60);r.toString().length<2&&(r="0"+r);var a=": ";n>1&&(a=" ("+i+" of "+n+"): "),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel+a+o+":"+r;var d=100*(t/e);this.progressDiv.style.width=d+"%"},i.prototype.unmute=function(){this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*this.controller.getPlayerVolume()+"%"},i.prototype.mute=function(){this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"},i.prototype.onAdVolumeSliderMouseDown=function(){document.addEventListener("mouseup",this.boundOnMouseUp,!1),document.addEventListener("mousemove",this.boundOnMouseMove,!1)},i.prototype.onMouseMove=function(t){this.changeVolume(t)},i.prototype.onMouseUp=function(t){this.changeVolume(t),document.removeEventListener("mouseup",this.boundOnMouseUp),document.removeEventListener("mousemove",this.boundOnMouseMove)},i.prototype.changeVolume=function(t){var e=(t.clientX-this.sliderDiv.getBoundingClientRect().left)/this.sliderDiv.offsetWidth;e*=100,e=Math.min(Math.max(e,0),100),this.sliderLevelDiv.style.width=e+"%",0==this.percent?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted")):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted")),this.controller.setVolume(e/100)},i.prototype.showAdContainer=function(){this.adContainerDiv.style.display="block"},i.prototype.onAdError=function(){this.adContainerDiv.style.display="none"},i.prototype.onAdBreakStart=function(t){this.adContainerDiv.style.display="block";"application/javascript"!==t.getAd().getContentType()||this.controller.getSettings().showControlsForJSAds?this.controlsDiv.style.display="block":this.controlsDiv.style.display="none",this.onAdsPlaying(),this.hideAdControls()},i.prototype.onAdBreakEnd=function(){var t=this.controller.getCurrentAd();(null==t||t.isLinear())&&(this.adContainerDiv.style.display="none"),this.controlsDiv.style.display="none",this.countdownDiv.innerHTML=""},i.prototype.onAllAdsCompleted=function(){this.adContainerDiv.style.display="none"},i.prototype.onLinearAdStart=function(){this.removeClass(this.adContainerDiv,"bumpable-ima-ad-container")},i.prototype.onNonLinearAdLoad=function(){this.adContainerDiv.style.display="block",this.addClass(this.adContainerDiv,"bumpable-ima-ad-container")},i.prototype.onPlayerResize=function(t,e){this.adsManager&&(this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.resize(t,e,google.ima.ViewMode.NORMAL))},i.prototype.onPlayerEnterFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-non-fullscreen")},i.prototype.onPlayerExitFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-fullscreen")},i.prototype.onPlayerVolumeChanged=function(t){0==t?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*t+"%")},i.prototype.showAdControls=function(){this.addClass(this.controlsDiv,"ima-controls-div-showing"),this.playPauseDiv.style.display="block",this.muteDiv.style.display="block",this.sliderDiv.style.display="block",this.fullscreenDiv.style.display="block"},i.prototype.hideAdControls=function(){this.removeClass(this.controlsDiv,"ima-controls-div-showing"),this.playPauseDiv.style.display="none",this.muteDiv.style.display="none",this.sliderDiv.style.display="none",this.fullscreenDiv.style.display="none"},i.prototype.assignControlAttributes=function(t,e){t.id=this.controlPrefix+e,t.className=this.controlPrefix+e+" "+e},i.prototype.getClassRegexp=function(t){return new RegExp("(^|[^A-Za-z-])"+t+"((?![A-Za-z-])|$)","gi")},i.prototype.elementHasClass=function(t,e){return this.getClassRegexp(e).test(t.className)},i.prototype.addClass=function(t,e){t.className=t.className.trim()+" "+e},i.prototype.removeClass=function(t,e){var i=this.getClassRegexp(e);t.className=t.className.trim().replace(i,"")},i.prototype.getAdContainerDiv=function(){return this.adContainerDiv},i.prototype.setShowCountdown=function(t){this.showCountdown=t,this.countdownDiv.style.display=this.showCountdown?"block":"none"};var n={name:"videojs-ima",version:"1.0.3",license:"Apache-2.0",main:"./dist/videojs.ima.js",author:{name:"Google Inc."},engines:{node:">=0.8.0"},scripts:{contBuild:"watch 'npm run rollup:max' src",devServer:"forever start ./node_modules/http-server/bin/http-server && npm run contBuild",postdevServer:"forever stop ./node_modules/http-server/bin/http-server",lint:'eslint "src/*.js"',rollup:"npm-run-all rollup:*","rollup:max":"rollup -c configs/rollup.config.js","rollup:min":"rollup -c configs/rollup.config.min.js",pretest:"npm run rollup",test:"npm-run-all -p -r testServer webdriver",testServer:"http-server",preversion:"npm run lint",version:"node scripts/version.js",postversion:"node scripts/postversion.js",webdriver:"mocha test/webdriver/*.js"},repository:{type:"git",url:"https://github.com/googleads/videojs-ima"},files:["CHANGELOG.md","LICENSE","README.md","dist/","src/"],dependencies:{"video.js":">=5.19.2","videojs-contrib-ads":"~5.1.0"},devDependencies:{"babel-core":"^6.26.0","babel-preset-env":"^1.6.1",child_process:"^1.0.2",chromedriver:"^2.33.2","conventional-changelog-cli":"^1.3.5","conventional-changelog-videojs":"^3.0.0",eslint:"^4.11.0","eslint-config-google":"^0.9.1","eslint-plugin-jsdoc":"^3.2.0",forever:"^0.15.3","http-server":"^0.10.0",mocha:"^4.0.1","npm-run-all":"^4.1.2",path:"^0.12.7",rimraf:"^2.6.2",rollup:"^0.51.8","rollup-plugin-babel":"^3.0.3","rollup-plugin-copy":"^0.2.3","rollup-plugin-json":"^2.3.0","rollup-plugin-uglify":"^2.0.1","selenium-webdriver":"^3.6.0","uglify-es":"^3.1.10",watch:"^1.0.2"}},s=function(t){this.controller=t,this.adDisplayContainer=null,this.adDisplayContainerInitialized=!1,this.adsLoader=null,this.adsManager=null,this.adsRenderingSettings=null,this.adTagUrl=null,this.adsResponse=null,this.currentAd=null,this.adTrackingTimer=null,this.allAdsCompleted=!1,this.adsActive=!1,this.adPlaying=!1,this.adMuted=!1,this.adBreakReadyListener=void 0,this.contentCompleteCalled=!1,this.adsManagerDimensions={width:0,height:0},this.autoPlayAdBreaks=!0,!1===this.controller.getSettings().autoPlayAdBreaks&&(this.autoPlayAdBreaks=!1),this.controller.getSettings().locale&&google.ima.settings.setLocale(this.controller.getSettings().locale),this.controller.getSettings().disableFlashAds&&google.ima.settings.setDisableFlashAds(this.controller.getSettings().disableFlashAds),this.controller.getSettings().disableCustomPlaybackForIOS10Plus&&google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.controller.getSettings().disableCustomPlaybackForIOS10Plus),this.initAdObjects(),(this.controller.getSettings().adTagUrl||this.controller.getSettings().adsResponse)&&this.requestAds()};s.prototype.initAdObjects=function(){this.adDisplayContainer=new google.ima.AdDisplayContainer(this.controller.getAdContainerDiv(),this.controller.getContentPlayer()),this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),0==this.controller.getSettings().vpaidAllowed&&this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.DISABLED),this.controller.getSettings().vpaidMode&&this.adsLoader.getSettings().setVpaidMode(this.controller.getSettings().vpaidMode),this.controller.getSettings().locale&&this.adsLoader.getSettings().setLocale(this.controller.getSettings.locale),this.controller.getSettings().numRedirects&&this.adsLoader.getSettings().setNumRedirects(this.controller.getSettings.numRedirects),this.adsLoader.getSettings().setPlayerType("videojs-ima"),this.adsLoader.getSettings().setPlayerVersion(n.version),this.adsLoader.getSettings().setAutoPlayAdBreaks(this.autoPlayAdBreaks),this.adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded.bind(this),!1),this.adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdsLoaderError.bind(this),!1)},s.prototype.requestAds=function(){var t=new google.ima.AdsRequest;this.controller.getSettings().adTagUrl?t.adTagUrl=this.controller.getSettings().adTagUrl:t.adsResponse=this.controller.getSettings().adsResponse,this.controller.getSettings().forceNonLinearFullSlot&&(t.forceNonLinearFullSlot=!0),t.linearAdSlotWidth=this.controller.getPlayerWidth(),t.linearAdSlotHeight=this.controller.getPlayerHeight(),t.nonLinearAdSlotWidth=this.controller.getSettings().nonLinearWidth||this.controller.getPlayerWidth(),t.nonLinearAdSlotHeight=this.controller.getSettings().nonLinearHeight||this.controller.getPlayerHeight()/3,t.setAdWillAutoPlay(this.controller.getSettings().adWillAutoPlay),t.setAdWillPlayMuted(this.controller.getSettings().adWillPlayMuted),this.adsLoader.requestAds(t)},s.prototype.onAdsManagerLoaded=function(t){this.createAdsRenderingSettings(),this.adsManager=t.getAdsManager(this.controller.getContentPlayheadTracker(),this.adsRenderingSettings),this.adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.AD_BREAK_READY,this.onAdBreakReady.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAllAdsCompleted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.LOADED,this.onAdLoaded.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.STARTED,this.onAdStarted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CLICK,this.onAdPaused.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE,this.onAdComplete.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED,this.onAdComplete.bind(this)),this.isMobile&&(this.adsManager.addEventListener(google.ima.AdEvent.Type.PAUSED,this.onAdPaused.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.RESUMED,this.onAdResumed.bind(this))),this.autoPlayAdBreaks||this.initAdsManager(),this.controller.onAdsReady(),this.controller.getSettings().adsManagerLoadedCallback&&this.controller.getSettings().adsManagerLoadedCallback()},s.prototype.onAdsLoaderError=function(t){window.console.warn("AdsLoader error: "+t.getError()),this.controller.onErrorLoadingAds(t),this.adsManager&&this.adsManager.destroy()},s.prototype.initAdsManager=function(){try{var t=this.controller.getPlayerWidth(),e=this.controller.getPlayerHeight();this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.init(t,e,google.ima.ViewMode.NORMAL),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adDisplayContainerInitialized||(this.adDisplayContainer.initialize(),this.adDisplayContainer.initialized=!0)}catch(t){this.onAdError(t)}},s.prototype.createAdsRenderingSettings=function(){if(this.adsRenderingSettings=new google.ima.AdsRenderingSettings,this.adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete=!0,this.controller.getSettings().adsRenderingSettings)for(var t in this.controller.getSettings().adsRenderingSettings)""!==t&&(this.adsRenderingSettings[t]=this.controller.getSettings().adsRenderingSettings[t])},s.prototype.onAdError=function(t){var e=void 0!==t.getError?t.getError():t.stack;window.console.warn("Ad error: "+e),this.adsManager.destroy(),this.controller.onAdError(t)},s.prototype.onAdBreakReady=function(t){this.adBreakReadyListener(t)},s.prototype.onContentPauseRequested=function(t){this.adsActive=!0,this.adPlaying=!0,this.controller.onAdBreakStart(t)},s.prototype.onContentResumeRequested=function(t){this.adsActive=!1,this.adPlaying=!1,this.controller.onAdBreakEnd()},s.prototype.onAllAdsCompleted=function(t){this.allAdsCompleted=!0,this.controller.onAllAdsCompleted()},s.prototype.onAdLoaded=function(t){t.getAd().isLinear()||(this.controller.onNonLinearAdLoad(),this.controller.playContent())},s.prototype.onAdStarted=function(t){this.currentAd=t.getAd(),this.currentAd.isLinear()?(this.adTrackingTimer=setInterval(this.onAdPlayheadTrackerInterval.bind(this),250),this.controller.onLinearAdStart()):this.controller.onNonLinearAdStart()},s.prototype.onAdPaused=function(){this.controller.onAdsPaused()},s.prototype.onAdResumed=function(t){this.controller.onAdsResumed()},s.prototype.onAdComplete=function(){this.currentAd.isLinear()&&clearInterval(this.adTrackingTimer)},s.prototype.onAdPlayheadTrackerInterval=function(){var t=this.adsManager.getRemainingTime(),e=this.currentAd.getDuration(),i=e-t;i=i>0?i:0;var n=0,s=void 0;this.currentAd.getAdPodInfo()&&(s=this.currentAd.getAdPodInfo().getAdPosition(),n=this.currentAd.getAdPodInfo().getTotalAds()),this.controller.onAdPlayheadUpdated(i,e,s,n)},s.prototype.onContentComplete=function(){this.adsLoader&&(this.adsLoader.contentComplete(),this.contentCompleteCalled=!0),this.allAdsCompleted&&this.controller.onContentAndAdsCompleted()},s.prototype.onPlayerDisposed=function(){this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null)},s.prototype.onPlayerReadyForPreroll=function(){if(this.autoPlayAdBreaks){this.initAdsManager();try{this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start()}catch(t){this.onAdError(t)}}},s.prototype.onPlayerEnterFullscreen=function(){this.adsManager&&this.adsManager.resize(window.screen.width,window.screen.height,google.ima.ViewMode.FULLSCREEN)},s.prototype.onPlayerExitFullscreen=function(){this.adsManager&&this.adsManager.resize(this.controller.getPlayerWidth(),this.controller.getPlayerHeight(),google.ima.ViewMode.NORMAL)},s.prototype.onPlayerVolumeChanged=function(t){this.adsManager&&this.adsManager.setVolume(t),this.adMuted=0==t},s.prototype.getCurrentAd=function(){return this.currentAd},s.prototype.setAdBreakReadyListener=function(t){this.adBreakReadyListener=t},s.prototype.isAdPlaying=function(){return this.adPlaying},s.prototype.isAdMuted=function(){return this.adMuted},s.prototype.pauseAds=function(){this.adsManager.pause(),this.adPlaying=!1},s.prototype.resumeAds=function(){this.adsManager.resume(),this.adPlaying=!0},s.prototype.unmute=function(){this.adsManager.setVolume(1),this.adMuted=!1},s.prototype.mute=function(){this.adsManager.setVolume(0),this.adMuted=!0},s.prototype.setVolume=function(t){this.adsManager.setVolume(t),this.adMuted=0==t},s.prototype.initializeAdDisplayContainer=function(){this.adDisplayContainerInitialized=!0,this.adDisplayContainer.initialize()},s.prototype.playAdBreak=function(){this.autoPlayAdBreaks||(this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start())},s.prototype.addEventListener=function(t,e){this.adsManager&&this.adsManager.addEventListener(t,e)},s.prototype.getAdsManager=function(){return this.adsManager},s.prototype.reset=function(){this.adsActive=!1,this.adPlaying=!1,this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null),this.adsLoader&&!this.contentCompleteCalled&&this.adsLoader.contentComplete(),this.contentCompleteCalled=!1,this.allAdsCompleted=!1};var o=function(t,n){this.settings={},this.contentAndAdsEndedListeners=[],this.isMobile=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i),this.initWithSettings(n);var o={debug:this.settings.debug,timeout:this.settings.timeout,prerollTimeout:this.settings.prerollTimeout},r=this.extend({},o,n.contribAdsSettings||{});this.playerWrapper=new e(t,r,this),this.adUi=new i(this),this.sdkImpl=new s(this)};o.IMA_DEFAULTS={debug:!1,timeout:5e3,prerollTimeout:1e3,adLabel:"Advertisement",showControlsForJSAds:!0,adWillPlayMuted:!1},o.prototype.initWithSettings=function(t){this.settings=this.extend({},o.IMA_DEFAULTS,t||{}),this.settings.id?(this.showCountdown=!0,!1===this.settings.showCountdown&&(this.showCountdown=!1)):window.console.error("Error: must provide id of video.js div")},o.prototype.getSettings=function(){return this.settings},o.prototype.injectAdContainerDiv=function(t){this.playerWrapper.injectAdContainerDiv(t)},o.prototype.getAdContainerDiv=function(){return this.adUi.getAdContainerDiv()},o.prototype.getContentPlayer=function(){return this.playerWrapper.getContentPlayer()},o.prototype.getContentPlayheadTracker=function(){return this.playerWrapper.getContentPlayheadTracker()},o.prototype.requestAds=function(){this.sdkImpl.requestAds()},o.prototype.setSetting=function(t,e){this.settings[t]=e},o.prototype.onErrorLoadingAds=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},o.prototype.onAdPlayPauseClick=function(){this.sdkImpl.isAdPlaying()?(this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()):(this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds())},o.prototype.onAdMuteClick=function(){this.sdkImpl.isAdMuted()?(this.playerWrapper.unmute(),this.adUi.unmute(),this.sdkImpl.unmute()):(this.playerWrapper.mute(),this.adUi.mute(),this.sdkImpl.mute())},o.prototype.setVolume=function(t){this.playerWrapper.setVolume(t),this.sdkImpl.setVolume(t)},o.prototype.getPlayerVolume=function(){return this.playerWrapper.getVolume()},o.prototype.toggleFullscreen=function(){this.playerWrapper.toggleFullscreen()},o.prototype.onAdError=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},o.prototype.onAdBreakStart=function(t){this.playerWrapper.onAdBreakStart(t),this.adUi.onAdBreakStart(t)},o.prototype.showAdContainer=function(){this.adUi.showAdContainer()},o.prototype.onAdBreakEnd=function(){this.playerWrapper.onAdBreakEnd(),this.adUi.onAdBreakEnd()},o.prototype.onAllAdsCompleted=function(){this.adUi.onAllAdsCompleted(),this.playerWrapper.onAllAdsCompleted()},o.prototype.onAdsPaused=function(){this.adUi.onAdsPaused()},o.prototype.onAdsResumed=function(){this.adUi.onAdsResumed()},o.prototype.onAdPlayheadUpdated=function(t,e,i,n){this.adUi.updateAdUi(t,e,i,n)},o.prototype.getCurrentAd=function(){return this.sdkImpl.getCurrentAd()},o.prototype.playContent=function(){this.playerWrapper.play()},o.prototype.onLinearAdStart=function(){this.adUi.onLinearAdStart(),this.playerWrapper.onAdStart()},o.prototype.onNonLinearAdLoad=function(){this.adUi.onNonLinearAdLoad()},o.prototype.onNonLinearAdStart=function(){this.adUi.onNonLinearAdLoad(),this.playerWrapper.onAdStart()},o.prototype.getPlayerWidth=function(){return this.playerWrapper.getPlayerWidth()},o.prototype.getPlayerHeight=function(){return this.playerWrapper.getPlayerHeight()},o.prototype.onAdsReady=function(){this.playerWrapper.onAdsReady()},o.prototype.onPlayerResize=function(t,e){this.adUi.onPlayerResize(t,e)},o.prototype.onContentComplete=function(){this.sdkImpl.onContentComplete()},o.prototype.onContentAndAdsCompleted=function(){for(var t in this.contentAndAdsEndedListeners)"function"==typeof this.contentAndAdsEndedListeners[t]&&this.contentAndAdsEndedListeners[t]()},o.prototype.onPlayerDisposed=function(){this.contentAndAdsEndedListeners=[],this.sdkImpl.onPlayerDisposed()},o.prototype.onPlayerReadyForPreroll=function(){this.sdkImpl.onPlayerReadyForPreroll()},o.prototype.onPlayerEnterFullscreen=function(){this.adUi.onPlayerEnterFullscreen(),this.sdkImpl.onPlayerEnterFullscreen()},o.prototype.onPlayerExitFullscreen=function(){this.adUi.onPlayerExitFullscreen(),this.sdkImpl.onPlayerExitFullscreen()},o.prototype.onPlayerVolumeChanged=function(t){this.adUi.onPlayerVolumeChanged(t),this.sdkImpl.onPlayerVolumeChanged(t)},o.prototype.setContentWithAdTag=function(t,e,i){this.reset(),this.settings.adTagUrl=e||this.settings.adTagUrl,this.playerWrapper.changeSource(t,i)},o.prototype.setContentWithAdsResponse=function(t,e,i){this.reset(),this.settings.adsResponse=e||this.settings.adsResponse,this.playerWrapper.changeSource(t,i)},o.prototype.reset=function(){this.sdkImpl.reset(),this.playerWrapper.reset()},o.prototype.addContentEndedListener=function(t){this.playerWrapper.addContentEndedListener(t)},o.prototype.addContentAndAdsEndedListener=function(t){this.contentAndAdsEndedListeners.push(t)},o.prototype.setAdBreakReadyListener=function(t){this.sdkImpl.setAdBreakReadyListener(t)},o.prototype.setShowCountdown=function(t){this.adUi.setShowCountdown(t),this.showCountdown=t,this.countdownDiv.style.display=this.showCountdown?"block":"none"},o.prototype.initializeAdDisplayContainer=function(){this.sdkImpl.initializeAdDisplayContainer()},o.prototype.playAdBreak=function(){this.sdkImpl.playAdBreak()},o.prototype.addEventListener=function(t,e){this.sdkImpl.addEventListener(t,e)},o.prototype.getAdsManager=function(){return this.sdkImpl.getAdsManager()},o.prototype.changeAdTag=function(t){this.reset(),this.settings.adTagUrl=t},o.prototype.pauseAd=function(){this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()},o.prototype.resumeAd=function(){this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds()},o.prototype.extend=function(t){for(var e=void 0,i=void 0,n=void 0,s=arguments.length,o=Array(s>1?s-1:0),r=1;r<s;r++)o[r-1]=arguments[r];for(i=0;i<o.length;i++){e=o[i];for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}return t};(t.registerPlugin||t.plugin)("ima",function(t){this.ima=new function(t,e){this.controller=new o(t,e),this.addContentAndAdsEndedListener=function(t){this.controller.addContentAndAdsEndedListener(t)}.bind(this),this.addContentEndedListener=function(t){this.controller.addContentEndedListener(t)}.bind(this),this.addEventListener=function(t,e){this.controller.addEventListener(t,e)}.bind(this),this.changeAdTag=function(t){this.controller.changeAdTag(t)}.bind(this),this.getAdsManager=function(){return this.controller.getAdsManager()}.bind(this),this.initializeAdDisplayContainer=function(){this.controller.initializeAdDisplayContainer()}.bind(this),this.pauseAd=function(){this.controller.pauseAd()}.bind(this),this.playAdBreak=function(){this.controller.playAdBreak()}.bind(this),this.requestAds=function(){this.controller.requestAds()}.bind(this),this.resumeAd=function(){this.controller.resumeAd()}.bind(this),this.setAdBreakReadyListener=function(t){this.controller.setAdBreakReadyListener()}.bind(this),this.setContentWithAdTag=function(t,e,i){this.controller.setContentWithAdTag(t,e,i)}.bind(this),this.setContentWithAdsResponse=function(t,e,i){this.controller.setContentWithAdsResponse(t,e,i)}.bind(this),this.setShowCountdown=function(t){this.controller.setShowCountdown(t)}.bind(this)}(this,t)})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],e):e(t.videojs)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e=function(t,e,i){this.vjsPlayer=t,this.controller=i,this.contentTrackingTimer=null,this.contentComplete=!1,this.updateTimeIntervalHandle=null,this.updateTimeInterval=1e3,this.seekCheckIntervalHandle=null,this.seekCheckInterval=1e3,this.resizeCheckIntervalHandle=null,this.resizeCheckInterval=250,this.seekThreshold=100,this.contentEndedListeners=[],this.contentSource="",this.contentPlayheadTracker={currentTime:0,previousTime:0,seeking:!1,duration:0},this.vjsPlayerDimensions={width:this.getPlayerWidth(),height:this.getPlayerHeight()},this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=document.getElementById(this.controller.getSettings().id).getElementsByClassName("vjs-tech")[0],this.h5Player.hasAttribute("autoplay")&&this.controller.setSetting("adWillAutoPlay",!0),this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this)),this.boundContentEndedListener=this.localContentEndedListener.bind(this),this.vjsPlayer.on("ended",this.boundContentEndedListener),this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("readyforpreroll",this.onReadyForPreroll.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),this.vjsPlayer.ads(e)};e.prototype.setUpPlayerIntervals=function(){this.updateTimeIntervalHandle=setInterval(this.updateCurrentTime.bind(this),this.updateTimeInterval),this.seekCheckIntervalHandle=setInterval(this.checkForSeeking.bind(this),this.seekCheckInterval),this.resizeCheckIntervalHandle=setInterval(this.checkForResize.bind(this),this.resizeCheckInterval)},e.prototype.updateCurrentTime=function(){this.contentPlayheadTracker.seeking||(this.contentPlayheadTracker.currentTime=this.vjsPlayer.currentTime())},e.prototype.checkForSeeking=function(){var t=1e3*(this.vjsPlayer.currentTime()-this.contentPlayheadTracker.previousTime);Math.abs(t)>this.seekCheckInterval+this.seekThreshold?this.contentPlayheadTracker.seeking=!0:this.contentPlayheadTracker.seeking=!1,this.contentPlayheadTracker.previousTime=this.vjsPlayer.currentTime()},e.prototype.checkForResize=function(){var t=this.getPlayerWidth(),e=this.getPlayerHeight();t==this.vjsPlayerDimensions.width&&e==this.vjsPlayerDimensions.height||(this.vjsPlayerDimensions.width=t,this.vjsPlayerDimensions.height=e,this.controller.onPlayerResize())},e.prototype.localContentEndedListener=function(){this.contentComplete||(this.contentComplete=!0,this.controller.onContentComplete());for(var t in this.contentEndedListeners)"function"==typeof this.contentEndedListeners[t]&&this.contentEndedListeners[t]();clearInterval(this.updateTimeIntervalHandle),clearInterval(this.seekCheckIntervalHandle),clearInterval(this.resizeCheckIntervalHandle),this.vjsPlayer.el()&&this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this))},e.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.controller.onPlayerDisposed(),this.contentComplete=!0,this.vjsPlayer.off("ended",this.localContentEndedListener),this.vjsPlayer.ads.adTimeoutTimeout&&clearTimeout(this.vjsPlayer.ads.adTimeoutTimeout);var t=[this.updateTimeIntervalHandle,this.seekCheckIntervalHandle,this.resizeCheckIntervalHandle];for(var e in t)t[e]&&clearInterval(t[e])},e.prototype.onReadyForPreroll=function(){this.controller.onPlayerReadyForPreroll()},e.prototype.onPlayerReady=function(){this.onVolumeChange(),this.vjsPlayer.on("fullscreenchange",this.onFullscreenChange.bind(this)),this.vjsPlayer.on("volumechange",this.onVolumeChange.bind(this))},e.prototype.onFullscreenChange=function(){this.vjsPlayer.isFullscreen()?this.controller.onPlayerEnterFullscreen():this.controller.onPlayerExitFullscreen()},e.prototype.onVolumeChange=function(){var t=this.vjsPlayer.muted()?0:this.vjsPlayer.volume();this.controller.onPlayerVolumeChanged(t)},e.prototype.injectAdContainerDiv=function(t){this.vjsControls.el().parentNode.appendChild(t)},e.prototype.getContentPlayer=function(){return this.h5Player},e.prototype.getVolume=function(){return this.vjsPlayer.muted()?0:this.vjsPlayer.volume()},e.prototype.setVolume=function(t){this.vjsPlayer.volume(t),0==t?this.vjsPlayer.muted(!0):this.vjsPlayer.muted(!1)},e.prototype.unmute=function(){this.vjsPlayer.muted(!1)},e.prototype.mute=function(){this.vjsPlayer.muted(!0)},e.prototype.play=function(){this.vjsPlayer.play()},e.prototype.getPlayerWidth=function(){var t=this.vjsPlayer.el().getBoundingClientRect()||{};return parseInt(t.width,10)||this.vjsPlayer.width()},e.prototype.getPlayerHeight=function(){var t=this.vjsPlayer.el().getBoundingClientRect()||{};return parseInt(t.height,10)||this.vjsPlayer.height()},e.prototype.toggleFullscreen=function(){this.vjsPlayer.isFullscreen()?this.vjsPlayer.exitFullscreen():this.vjsPlayer.requestFullscreen()},e.prototype.getContentPlayheadTracker=function(){return this.contentPlayheadTracker},e.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},e.prototype.onAdBreakStart=function(t){this.contentSource=this.vjsPlayer.currentSrc(),this.vjsPlayer.off("ended",this.boundContentEndedListener),-1!=t.getAd().getAdPodInfo().getPodIndex()&&this.vjsPlayer.ads.startLinearAdMode(),this.vjsControls.hide(),this.vjsPlayer.pause()},e.prototype.onAdBreakEnd=function(){this.vjsPlayer.on("ended",this.boundContentEndedListener),this.vjsPlayer.ads.endLinearAdMode(),this.vjsControls.show()},e.prototype.onAdStart=function(){this.vjsPlayer.trigger("ads-ad-started")},e.prototype.onAllAdsCompleted=function(){1==this.contentComplete&&(this.h5Player.src!=this.contentSource&&this.vjsPlayer.src(this.contentSource),this.controller.onContentAndAdsCompleted())},e.prototype.onAdsReady=function(){this.vjsPlayer.trigger("adsready")},e.prototype.changeSource=function(t,e){this.vjsPlayer.currentSrc()&&(this.vjsPlayer.currentTime(0),this.vjsPlayer.pause()),t&&this.vjsPlayer.src(t),e?this.vjsPlayer.one("loadedmetadata",this.playContentFromZero.bind(this)):this.vjsPlayer.one("loadedmetadata",this.seekContentToZero.bind(this))},e.prototype.seekContentToZero=function(){this.vjsPlayer.currentTime(0)},e.prototype.playContentFromZero=function(){this.vjsPlayer.currentTime(0),this.vjsPlayer.play()},e.prototype.addContentEndedListener=function(t){this.contentEndedListeners.push(t)},e.prototype.reset=function(){this.vjsPlayer.on("ended",this.boundContentEndedListener),this.vjsControls.show(),this.vjsPlayer.ads.endLinearAdMode(),this.contentPlayheadTracker.currentTime=0};var i=function(t){this.controller=t,this.adContainerDiv=document.createElement("div"),this.controlsDiv=document.createElement("div"),this.countdownDiv=document.createElement("div"),this.seekBarDiv=document.createElement("div"),this.progressDiv=document.createElement("div"),this.playPauseDiv=document.createElement("div"),this.muteDiv=document.createElement("div"),this.sliderDiv=document.createElement("div"),this.sliderLevelDiv=document.createElement("div"),this.fullscreenDiv=document.createElement("div"),this.boundOnMouseUp=this.onMouseUp.bind(this),this.boundOnMouseUp=this.onMouseMove.bind(this),this.adPlayheadTracker={currentTime:0,duration:0,isPod:!1,adPosition:0,totalAds:0},this.controlPrefix=this.controller.getSettings().id?this.controller.getSettings().id+"_":"",this.showCountdown=!0,!1===this.controller.getSettings().showCountdown&&(this.showCountdown=!1),this.createAdContainer()};i.prototype.createAdContainer=function(){this.assignControlAttributes(this.adContainerDiv,"ima-ad-container"),this.adContainerDiv.style.position="absolute",this.adContainerDiv.style.zIndex=1111,this.adContainerDiv.addEventListener("mouseenter",this.showAdControls.bind(this),!1),this.adContainerDiv.addEventListener("mouseleave",this.hideAdControls.bind(this),!1),this.createControls(),this.controller.injectAdContainerDiv(this.adContainerDiv)},i.prototype.createControls=function(){this.assignControlAttributes(this.controlsDiv,"ima-controls-div"),this.controlsDiv.style.width="100%",this.assignControlAttributes(this.countdownDiv,"ima-countdown-div"),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel,this.countdownDiv.style.display=this.showCountdown?"block":"none",this.assignControlAttributes(this.seekBarDiv,"ima-seek-bar-div"),this.seekBarDiv.style.width="100%",this.assignControlAttributes(this.progressDiv,"ima-progress-div"),this.assignControlAttributes(this.playPauseDiv,"ima-play-pause-div"),this.addClass(this.playPauseDiv,"ima-playing"),this.playPauseDiv.addEventListener("click",this.onAdPlayPauseClick.bind(this),!1),this.assignControlAttributes(this.muteDiv,"ima-mute-div"),this.addClass(this.muteDiv,"ima-non-muted"),this.muteDiv.addEventListener("click",this.onAdMuteClick.bind(this),!1),this.assignControlAttributes(this.sliderDiv,"ima-slider-div"),this.sliderDiv.addEventListener("mousedown",this.onAdVolumeSliderMouseDown.bind(this),!1),this.assignControlAttributes(this.sliderLevelDiv,"ima-slider-level-div"),this.assignControlAttributes(this.fullscreenDiv,"ima-fullscreen-div"),this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.fullscreenDiv.addEventListener("click",this.onAdFullscreenClick.bind(this),!1),this.adContainerDiv.appendChild(this.controlsDiv),this.controlsDiv.appendChild(this.countdownDiv),this.controlsDiv.appendChild(this.seekBarDiv),this.controlsDiv.appendChild(this.playPauseDiv),this.controlsDiv.appendChild(this.muteDiv),this.controlsDiv.appendChild(this.sliderDiv),this.controlsDiv.appendChild(this.fullscreenDiv),this.seekBarDiv.appendChild(this.progressDiv),this.sliderDiv.appendChild(this.sliderLevelDiv)},i.prototype.onAdPlayPauseClick=function(){this.controller.onAdPlayPauseClick()},i.prototype.onAdMuteClick=function(){this.controller.onAdMuteClick()},i.prototype.onAdFullscreenClick=function(){this.controller.toggleFullscreen()},i.prototype.onAdsPaused=function(){this.addClass(this.playPauseDiv,"ima-paused"),this.removeClass(this.playPauseDiv,"ima-playing"),this.showAdControls()},i.prototype.onAdsResumed=function(){this.onAdsPlaying(),this.showAdControls()},i.prototype.onAdsPlaying=function(){this.addClass(this.playPauseDiv,"ima-playing"),this.removeClass(this.playPauseDiv,"ima-paused")},i.prototype.updateAdUi=function(t,e,i,n){var s=e-t,o=Math.floor(s/60),r=Math.floor(s%60);r.toString().length<2&&(r="0"+r);var a=": ";n>1&&(a=" ("+i+" of "+n+"): "),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel+a+o+":"+r;var d=100*(t/e);this.progressDiv.style.width=d+"%"},i.prototype.unmute=function(){this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*this.controller.getPlayerVolume()+"%"},i.prototype.mute=function(){this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"},i.prototype.onAdVolumeSliderMouseDown=function(){document.addEventListener("mouseup",this.boundOnMouseUp,!1),document.addEventListener("mousemove",this.boundOnMouseMove,!1)},i.prototype.onMouseMove=function(t){this.changeVolume(t)},i.prototype.onMouseUp=function(t){this.changeVolume(t),document.removeEventListener("mouseup",this.boundOnMouseUp),document.removeEventListener("mousemove",this.boundOnMouseMove)},i.prototype.changeVolume=function(t){var e=(t.clientX-this.sliderDiv.getBoundingClientRect().left)/this.sliderDiv.offsetWidth;e*=100,e=Math.min(Math.max(e,0),100),this.sliderLevelDiv.style.width=e+"%",0==this.percent?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted")):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted")),this.controller.setVolume(e/100)},i.prototype.showAdContainer=function(){this.adContainerDiv.style.display="block"},i.prototype.onAdError=function(){this.adContainerDiv.style.display="none"},i.prototype.onAdBreakStart=function(t){this.adContainerDiv.style.display="block";"application/javascript"!==t.getAd().getContentType()||this.controller.getSettings().showControlsForJSAds?this.controlsDiv.style.display="block":this.controlsDiv.style.display="none",this.onAdsPlaying(),this.hideAdControls()},i.prototype.onAdBreakEnd=function(){var t=this.controller.getCurrentAd();(null==t||t.isLinear())&&(this.adContainerDiv.style.display="none"),this.controlsDiv.style.display="none",this.countdownDiv.innerHTML=""},i.prototype.onAllAdsCompleted=function(){this.adContainerDiv.style.display="none"},i.prototype.onLinearAdStart=function(){this.removeClass(this.adContainerDiv,"bumpable-ima-ad-container")},i.prototype.onNonLinearAdLoad=function(){this.adContainerDiv.style.display="block",this.addClass(this.adContainerDiv,"bumpable-ima-ad-container")},i.prototype.onPlayerResize=function(t,e){this.adsManager&&(this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.resize(t,e,google.ima.ViewMode.NORMAL))},i.prototype.onPlayerEnterFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-non-fullscreen")},i.prototype.onPlayerExitFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-fullscreen")},i.prototype.onPlayerVolumeChanged=function(t){0==t?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*t+"%")},i.prototype.showAdControls=function(){this.addClass(this.controlsDiv,"ima-controls-div-showing"),this.playPauseDiv.style.display="block",this.muteDiv.style.display="block",this.sliderDiv.style.display="block",this.fullscreenDiv.style.display="block"},i.prototype.hideAdControls=function(){this.removeClass(this.controlsDiv,"ima-controls-div-showing"),this.playPauseDiv.style.display="none",this.muteDiv.style.display="none",this.sliderDiv.style.display="none",this.fullscreenDiv.style.display="none"},i.prototype.assignControlAttributes=function(t,e){t.id=this.controlPrefix+e,t.className=this.controlPrefix+e+" "+e},i.prototype.getClassRegexp=function(t){return new RegExp("(^|[^A-Za-z-])"+t+"((?![A-Za-z-])|$)","gi")},i.prototype.elementHasClass=function(t,e){return this.getClassRegexp(e).test(t.className)},i.prototype.addClass=function(t,e){t.className=t.className.trim()+" "+e},i.prototype.removeClass=function(t,e){var i=this.getClassRegexp(e);t.className=t.className.trim().replace(i,"")},i.prototype.getAdContainerDiv=function(){return this.adContainerDiv},i.prototype.setShowCountdown=function(t){this.showCountdown=t,this.countdownDiv.style.display=this.showCountdown?"block":"none"};var n={name:"videojs-ima",version:"1.0.4",license:"Apache-2.0",main:"./dist/videojs.ima.js",author:{name:"Google Inc."},engines:{node:">=0.8.0"},scripts:{contBuild:"watch 'npm run rollup:max' src",devServer:"forever start ./node_modules/http-server/bin/http-server && npm run contBuild",postdevServer:"forever stop ./node_modules/http-server/bin/http-server",lint:'eslint "src/*.js"',rollup:"npm-run-all rollup:*","rollup:max":"rollup -c configs/rollup.config.js","rollup:min":"rollup -c configs/rollup.config.min.js",pretest:"npm run rollup",test:"npm-run-all -p -r testServer webdriver",testServer:"http-server",preversion:"npm run lint",version:"node scripts/version.js",postversion:"node scripts/postversion.js",webdriver:"mocha test/webdriver/*.js"},repository:{type:"git",url:"https://github.com/googleads/videojs-ima"},files:["CHANGELOG.md","LICENSE","README.md","dist/","src/"],dependencies:{"video.js":">=5.19.2","videojs-contrib-ads":"~5.1.0"},devDependencies:{"babel-core":"^6.26.0","babel-preset-env":"^1.6.1",child_process:"^1.0.2",chromedriver:"^2.33.2","conventional-changelog-cli":"^1.3.5","conventional-changelog-videojs":"^3.0.0",eslint:"^4.11.0","eslint-config-google":"^0.9.1","eslint-plugin-jsdoc":"^3.2.0",forever:"^0.15.3","http-server":"^0.10.0",mocha:"^4.0.1","npm-run-all":"^4.1.2",path:"^0.12.7",rimraf:"^2.6.2",rollup:"^0.51.8","rollup-plugin-babel":"^3.0.3","rollup-plugin-copy":"^0.2.3","rollup-plugin-json":"^2.3.0","rollup-plugin-uglify":"^2.0.1","selenium-webdriver":"^3.6.0","uglify-es":"^3.1.10",watch:"^1.0.2"},keywords:["videojs","videojs-plugin"]},s=function(t){this.controller=t,this.adDisplayContainer=null,this.adDisplayContainerInitialized=!1,this.adsLoader=null,this.adsManager=null,this.adsRenderingSettings=null,this.adTagUrl=null,this.adsResponse=null,this.currentAd=null,this.adTrackingTimer=null,this.allAdsCompleted=!1,this.adsActive=!1,this.adPlaying=!1,this.adMuted=!1,this.adBreakReadyListener=void 0,this.contentCompleteCalled=!1,this.adsManagerDimensions={width:0,height:0},this.autoPlayAdBreaks=!0,!1===this.controller.getSettings().autoPlayAdBreaks&&(this.autoPlayAdBreaks=!1),this.controller.getSettings().locale&&google.ima.settings.setLocale(this.controller.getSettings().locale),this.controller.getSettings().disableFlashAds&&google.ima.settings.setDisableFlashAds(this.controller.getSettings().disableFlashAds),this.controller.getSettings().disableCustomPlaybackForIOS10Plus&&google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.controller.getSettings().disableCustomPlaybackForIOS10Plus),this.initAdObjects(),(this.controller.getSettings().adTagUrl||this.controller.getSettings().adsResponse)&&this.requestAds()};s.prototype.initAdObjects=function(){this.adDisplayContainer=new google.ima.AdDisplayContainer(this.controller.getAdContainerDiv(),this.controller.getContentPlayer()),this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),0==this.controller.getSettings().vpaidAllowed&&this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.DISABLED),this.controller.getSettings().vpaidMode&&this.adsLoader.getSettings().setVpaidMode(this.controller.getSettings().vpaidMode),this.controller.getSettings().locale&&this.adsLoader.getSettings().setLocale(this.controller.getSettings.locale),this.controller.getSettings().numRedirects&&this.adsLoader.getSettings().setNumRedirects(this.controller.getSettings.numRedirects),this.adsLoader.getSettings().setPlayerType("videojs-ima"),this.adsLoader.getSettings().setPlayerVersion(n.version),this.adsLoader.getSettings().setAutoPlayAdBreaks(this.autoPlayAdBreaks),this.adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded.bind(this),!1),this.adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdsLoaderError.bind(this),!1)},s.prototype.requestAds=function(){var t=new google.ima.AdsRequest;this.controller.getSettings().adTagUrl?t.adTagUrl=this.controller.getSettings().adTagUrl:t.adsResponse=this.controller.getSettings().adsResponse,this.controller.getSettings().forceNonLinearFullSlot&&(t.forceNonLinearFullSlot=!0),t.linearAdSlotWidth=this.controller.getPlayerWidth(),t.linearAdSlotHeight=this.controller.getPlayerHeight(),t.nonLinearAdSlotWidth=this.controller.getSettings().nonLinearWidth||this.controller.getPlayerWidth(),t.nonLinearAdSlotHeight=this.controller.getSettings().nonLinearHeight||this.controller.getPlayerHeight()/3,t.setAdWillAutoPlay(this.controller.getSettings().adWillAutoPlay),t.setAdWillPlayMuted(this.controller.getSettings().adWillPlayMuted),this.adsLoader.requestAds(t)},s.prototype.onAdsManagerLoaded=function(t){this.createAdsRenderingSettings(),this.adsManager=t.getAdsManager(this.controller.getContentPlayheadTracker(),this.adsRenderingSettings),this.adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.AD_BREAK_READY,this.onAdBreakReady.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAllAdsCompleted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.LOADED,this.onAdLoaded.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.STARTED,this.onAdStarted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CLICK,this.onAdPaused.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE,this.onAdComplete.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED,this.onAdComplete.bind(this)),this.isMobile&&(this.adsManager.addEventListener(google.ima.AdEvent.Type.PAUSED,this.onAdPaused.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.RESUMED,this.onAdResumed.bind(this))),this.autoPlayAdBreaks||this.initAdsManager(),this.controller.onAdsReady(),this.controller.getSettings().adsManagerLoadedCallback&&this.controller.getSettings().adsManagerLoadedCallback()},s.prototype.onAdsLoaderError=function(t){window.console.warn("AdsLoader error: "+t.getError()),this.controller.onErrorLoadingAds(t),this.adsManager&&this.adsManager.destroy()},s.prototype.initAdsManager=function(){try{var t=this.controller.getPlayerWidth(),e=this.controller.getPlayerHeight();this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.init(t,e,google.ima.ViewMode.NORMAL),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adDisplayContainerInitialized||(this.adDisplayContainer.initialize(),this.adDisplayContainer.initialized=!0)}catch(t){this.onAdError(t)}},s.prototype.createAdsRenderingSettings=function(){if(this.adsRenderingSettings=new google.ima.AdsRenderingSettings,this.adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete=!0,this.controller.getSettings().adsRenderingSettings)for(var t in this.controller.getSettings().adsRenderingSettings)""!==t&&(this.adsRenderingSettings[t]=this.controller.getSettings().adsRenderingSettings[t])},s.prototype.onAdError=function(t){var e=void 0!==t.getError?t.getError():t.stack;window.console.warn("Ad error: "+e),this.adsManager.destroy(),this.controller.onAdError(t)},s.prototype.onAdBreakReady=function(t){this.adBreakReadyListener(t)},s.prototype.onContentPauseRequested=function(t){this.adsActive=!0,this.adPlaying=!0,this.controller.onAdBreakStart(t)},s.prototype.onContentResumeRequested=function(t){this.adsActive=!1,this.adPlaying=!1,this.controller.onAdBreakEnd()},s.prototype.onAllAdsCompleted=function(t){this.allAdsCompleted=!0,this.controller.onAllAdsCompleted()},s.prototype.onAdLoaded=function(t){t.getAd().isLinear()||(this.controller.onNonLinearAdLoad(),this.controller.playContent())},s.prototype.onAdStarted=function(t){this.currentAd=t.getAd(),this.currentAd.isLinear()?(this.adTrackingTimer=setInterval(this.onAdPlayheadTrackerInterval.bind(this),250),this.controller.onLinearAdStart()):this.controller.onNonLinearAdStart()},s.prototype.onAdPaused=function(){this.controller.onAdsPaused()},s.prototype.onAdResumed=function(t){this.controller.onAdsResumed()},s.prototype.onAdComplete=function(){this.currentAd.isLinear()&&clearInterval(this.adTrackingTimer)},s.prototype.onAdPlayheadTrackerInterval=function(){var t=this.adsManager.getRemainingTime(),e=this.currentAd.getDuration(),i=e-t;i=i>0?i:0;var n=0,s=void 0;this.currentAd.getAdPodInfo()&&(s=this.currentAd.getAdPodInfo().getAdPosition(),n=this.currentAd.getAdPodInfo().getTotalAds()),this.controller.onAdPlayheadUpdated(i,e,s,n)},s.prototype.onContentComplete=function(){this.adsLoader&&(this.adsLoader.contentComplete(),this.contentCompleteCalled=!0),this.allAdsCompleted&&this.controller.onContentAndAdsCompleted()},s.prototype.onPlayerDisposed=function(){this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null)},s.prototype.onPlayerReadyForPreroll=function(){if(this.autoPlayAdBreaks){this.initAdsManager();try{this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start()}catch(t){this.onAdError(t)}}},s.prototype.onPlayerEnterFullscreen=function(){this.adsManager&&this.adsManager.resize(window.screen.width,window.screen.height,google.ima.ViewMode.FULLSCREEN)},s.prototype.onPlayerExitFullscreen=function(){this.adsManager&&this.adsManager.resize(this.controller.getPlayerWidth(),this.controller.getPlayerHeight(),google.ima.ViewMode.NORMAL)},s.prototype.onPlayerVolumeChanged=function(t){this.adsManager&&this.adsManager.setVolume(t),this.adMuted=0==t},s.prototype.getCurrentAd=function(){return this.currentAd},s.prototype.setAdBreakReadyListener=function(t){this.adBreakReadyListener=t},s.prototype.isAdPlaying=function(){return this.adPlaying},s.prototype.isAdMuted=function(){return this.adMuted},s.prototype.pauseAds=function(){this.adsManager.pause(),this.adPlaying=!1},s.prototype.resumeAds=function(){this.adsManager.resume(),this.adPlaying=!0},s.prototype.unmute=function(){this.adsManager.setVolume(1),this.adMuted=!1},s.prototype.mute=function(){this.adsManager.setVolume(0),this.adMuted=!0},s.prototype.setVolume=function(t){this.adsManager.setVolume(t),this.adMuted=0==t},s.prototype.initializeAdDisplayContainer=function(){this.adDisplayContainerInitialized=!0,this.adDisplayContainer.initialize()},s.prototype.playAdBreak=function(){this.autoPlayAdBreaks||(this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start())},s.prototype.addEventListener=function(t,e){this.adsManager&&this.adsManager.addEventListener(t,e)},s.prototype.getAdsManager=function(){return this.adsManager},s.prototype.reset=function(){this.adsActive=!1,this.adPlaying=!1,this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null),this.adsLoader&&!this.contentCompleteCalled&&this.adsLoader.contentComplete(),this.contentCompleteCalled=!1,this.allAdsCompleted=!1};var o=function(t,n){this.settings={},this.contentAndAdsEndedListeners=[],this.isMobile=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i),this.initWithSettings(n);var o={debug:this.settings.debug,timeout:this.settings.timeout,prerollTimeout:this.settings.prerollTimeout},r=this.extend({},o,n.contribAdsSettings||{});this.playerWrapper=new e(t,r,this),this.adUi=new i(this),this.sdkImpl=new s(this)};o.IMA_DEFAULTS={debug:!1,timeout:5e3,prerollTimeout:1e3,adLabel:"Advertisement",showControlsForJSAds:!0,adWillPlayMuted:!1},o.prototype.initWithSettings=function(t){this.settings=this.extend({},o.IMA_DEFAULTS,t||{}),this.settings.id?(this.showCountdown=!0,!1===this.settings.showCountdown&&(this.showCountdown=!1)):window.console.error("Error: must provide id of video.js div")},o.prototype.getSettings=function(){return this.settings},o.prototype.injectAdContainerDiv=function(t){this.playerWrapper.injectAdContainerDiv(t)},o.prototype.getAdContainerDiv=function(){return this.adUi.getAdContainerDiv()},o.prototype.getContentPlayer=function(){return this.playerWrapper.getContentPlayer()},o.prototype.getContentPlayheadTracker=function(){return this.playerWrapper.getContentPlayheadTracker()},o.prototype.requestAds=function(){this.sdkImpl.requestAds()},o.prototype.setSetting=function(t,e){this.settings[t]=e},o.prototype.onErrorLoadingAds=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},o.prototype.onAdPlayPauseClick=function(){this.sdkImpl.isAdPlaying()?(this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()):(this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds())},o.prototype.onAdMuteClick=function(){this.sdkImpl.isAdMuted()?(this.playerWrapper.unmute(),this.adUi.unmute(),this.sdkImpl.unmute()):(this.playerWrapper.mute(),this.adUi.mute(),this.sdkImpl.mute())},o.prototype.setVolume=function(t){this.playerWrapper.setVolume(t),this.sdkImpl.setVolume(t)},o.prototype.getPlayerVolume=function(){return this.playerWrapper.getVolume()},o.prototype.toggleFullscreen=function(){this.playerWrapper.toggleFullscreen()},o.prototype.onAdError=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},o.prototype.onAdBreakStart=function(t){this.playerWrapper.onAdBreakStart(t),this.adUi.onAdBreakStart(t)},o.prototype.showAdContainer=function(){this.adUi.showAdContainer()},o.prototype.onAdBreakEnd=function(){this.playerWrapper.onAdBreakEnd(),this.adUi.onAdBreakEnd()},o.prototype.onAllAdsCompleted=function(){this.adUi.onAllAdsCompleted(),this.playerWrapper.onAllAdsCompleted()},o.prototype.onAdsPaused=function(){this.adUi.onAdsPaused()},o.prototype.onAdsResumed=function(){this.adUi.onAdsResumed()},o.prototype.onAdPlayheadUpdated=function(t,e,i,n){this.adUi.updateAdUi(t,e,i,n)},o.prototype.getCurrentAd=function(){return this.sdkImpl.getCurrentAd()},o.prototype.playContent=function(){this.playerWrapper.play()},o.prototype.onLinearAdStart=function(){this.adUi.onLinearAdStart(),this.playerWrapper.onAdStart()},o.prototype.onNonLinearAdLoad=function(){this.adUi.onNonLinearAdLoad()},o.prototype.onNonLinearAdStart=function(){this.adUi.onNonLinearAdLoad(),this.playerWrapper.onAdStart()},o.prototype.getPlayerWidth=function(){return this.playerWrapper.getPlayerWidth()},o.prototype.getPlayerHeight=function(){return this.playerWrapper.getPlayerHeight()},o.prototype.onAdsReady=function(){this.playerWrapper.onAdsReady()},o.prototype.onPlayerResize=function(t,e){this.adUi.onPlayerResize(t,e)},o.prototype.onContentComplete=function(){this.sdkImpl.onContentComplete()},o.prototype.onContentAndAdsCompleted=function(){for(var t in this.contentAndAdsEndedListeners)"function"==typeof this.contentAndAdsEndedListeners[t]&&this.contentAndAdsEndedListeners[t]()},o.prototype.onPlayerDisposed=function(){this.contentAndAdsEndedListeners=[],this.sdkImpl.onPlayerDisposed()},o.prototype.onPlayerReadyForPreroll=function(){this.sdkImpl.onPlayerReadyForPreroll()},o.prototype.onPlayerEnterFullscreen=function(){this.adUi.onPlayerEnterFullscreen(),this.sdkImpl.onPlayerEnterFullscreen()},o.prototype.onPlayerExitFullscreen=function(){this.adUi.onPlayerExitFullscreen(),this.sdkImpl.onPlayerExitFullscreen()},o.prototype.onPlayerVolumeChanged=function(t){this.adUi.onPlayerVolumeChanged(t),this.sdkImpl.onPlayerVolumeChanged(t)},o.prototype.setContentWithAdTag=function(t,e,i){this.reset(),this.settings.adTagUrl=e||this.settings.adTagUrl,this.playerWrapper.changeSource(t,i)},o.prototype.setContentWithAdsResponse=function(t,e,i){this.reset(),this.settings.adsResponse=e||this.settings.adsResponse,this.playerWrapper.changeSource(t,i)},o.prototype.reset=function(){this.sdkImpl.reset(),this.playerWrapper.reset()},o.prototype.addContentEndedListener=function(t){this.playerWrapper.addContentEndedListener(t)},o.prototype.addContentAndAdsEndedListener=function(t){this.contentAndAdsEndedListeners.push(t)},o.prototype.setAdBreakReadyListener=function(t){this.sdkImpl.setAdBreakReadyListener(t)},o.prototype.setShowCountdown=function(t){this.adUi.setShowCountdown(t),this.showCountdown=t,this.countdownDiv.style.display=this.showCountdown?"block":"none"},o.prototype.initializeAdDisplayContainer=function(){this.sdkImpl.initializeAdDisplayContainer()},o.prototype.playAdBreak=function(){this.sdkImpl.playAdBreak()},o.prototype.addEventListener=function(t,e){this.sdkImpl.addEventListener(t,e)},o.prototype.getAdsManager=function(){return this.sdkImpl.getAdsManager()},o.prototype.changeAdTag=function(t){this.reset(),this.settings.adTagUrl=t},o.prototype.pauseAd=function(){this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()},o.prototype.resumeAd=function(){this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds()},o.prototype.extend=function(t){for(var e=void 0,i=void 0,n=void 0,s=arguments.length,o=Array(s>1?s-1:0),r=1;r<s;r++)o[r-1]=arguments[r];for(i=0;i<o.length;i++){e=o[i];for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}return t};(t.registerPlugin||t.plugin)("ima",function(t){this.ima=new function(t,e){this.controller=new o(t,e),this.addContentAndAdsEndedListener=function(t){this.controller.addContentAndAdsEndedListener(t)}.bind(this),this.addContentEndedListener=function(t){this.controller.addContentEndedListener(t)}.bind(this),this.addEventListener=function(t,e){this.controller.addEventListener(t,e)}.bind(this),this.changeAdTag=function(t){this.controller.changeAdTag(t)}.bind(this),this.getAdsManager=function(){return this.controller.getAdsManager()}.bind(this),this.initializeAdDisplayContainer=function(){this.controller.initializeAdDisplayContainer()}.bind(this),this.pauseAd=function(){this.controller.pauseAd()}.bind(this),this.playAdBreak=function(){this.controller.playAdBreak()}.bind(this),this.requestAds=function(){this.controller.requestAds()}.bind(this),this.resumeAd=function(){this.controller.resumeAd()}.bind(this),this.setAdBreakReadyListener=function(t){this.controller.setAdBreakReadyListener()}.bind(this),this.setContentWithAdTag=function(t,e,i){this.controller.setContentWithAdTag(t,e,i)}.bind(this),this.setContentWithAdsResponse=function(t,e,i){this.controller.setContentWithAdsResponse(t,e,i)}.bind(this),this.setShowCountdown=function(t){this.controller.setShowCountdown(t)}.bind(this)}(this,t)})}); |
{ | ||
"name": "videojs-ima", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "Apache-2.0", | ||
@@ -67,3 +67,7 @@ "main": "./dist/videojs.ima.js", | ||
"watch": "^1.0.2" | ||
} | ||
}, | ||
"keywords": [ | ||
"videojs", | ||
"videojs-plugin" | ||
] | ||
} |
@@ -36,3 +36,3 @@ # IMA SDK Plugin for Video.js | ||
<!-- Load dependent stylesheets. --> | ||
<link href="//vjs.zencdn.net/4.5/video-js.css" rel="stylesheet"> | ||
<link href="path/to/video-js.css" rel="stylesheet"> | ||
<link rel="stylesheet" href="path/to/videojs-contrib-ads.css" /> | ||
@@ -48,3 +48,3 @@ <link rel="stylesheet" href="path/to/videojs.ima.css" /> | ||
<!-- Load dependent scripts --> | ||
<script src="//vjs.zencdn.net/4.5/video.js"></script> | ||
<script src="/path/to/video.js"></script> | ||
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script> | ||
@@ -68,3 +68,2 @@ <script src="/path/to/videojs-contrib-ads.js"></script> | ||
// This must be called before player.play() below. | ||
player.ima(options); | ||
@@ -80,2 +79,5 @@ // On mobile devices, you must call initializeAdDisplayContainer as the result | ||
## Playground | ||
Check out the snippet above in-action [on CodePen](https://codepen.io/imasdk/pen/wpyQXP). | ||
## Additional settings | ||
@@ -82,0 +84,0 @@ The plugin accepts additional settings beyond the two required settings shown in |
Sorry, the diff of this file is too big to display
212916
4964
144