flowplayer-vast
Version:
VAST 2.0 support within Flowplayer 6 HTML
5 lines (3 loc) • 29.5 kB
JavaScript
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
!function(){return function e(t,n,r){function i(o,a){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){return i(t[o][1][e]||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(e,t,n){var r=Object.create||function(e){var t=function(){};return t.prototype=e,new t},i=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},s=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var a,l=10;try{var u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),a=0===u.x}catch(e){a=!1}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function h(e,t,n,i){var s,o,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]):(o=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=o[t]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),!a.warned&&(s=c(e))&&s>0&&a.length>s){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=o[t]=n,++e._eventsCount;return e}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=s.call(p,r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(!r)return[];var i=r[t];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):v(i,i.length):[]}function m(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function v(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}a?Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');l=e}}):o.defaultMaxListeners=l,o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){var t,n,r,i,s,o,a="error"===e;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var l=new Error('Unhandled "error" event. ('+t+")");throw l.context=t,l}if(!(n=o[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=v(e,r),s=0;s<r;++s)i[s].call(n)}(n,u,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=v(e,i),o=0;o<i;++o)s[o].call(n,r)}(n,u,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,o=v(e,s),a=0;a<s;++a)o[a].call(n,r,i)}(n,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var o=e.length,a=v(e,o),l=0;l<o;++l)a[l].call(n,r,i,s)}(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=v(e,i),o=0;o<i;++o)s[o].apply(n,r)}(n,u,this,i)}return!0},o.prototype.addListener=function(e,t){return h(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return h(this,e,t,!0)},o.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,f(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,f(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,i,s,o,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,s=o;break}if(s<0)return this;0===s?n.shift():function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,s),1===n.length&&(i[e]=n[0]),i.removeListener&&this.emit("removeListener",e,a||t)}return this},o.prototype.removeAllListeners=function(e){var t,n,s;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var o,a=i(n);for(s=0;s<a.length;++s)"removeListener"!==(o=a[s])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],2:[function(e,t,n){(function(){var e;e=function(){return function(){this.id=null,this.errorURLTemplates=[],this.impressionURLTemplates=[],this.creatives=[]}}(),t.exports=e}).call(this)},{}],3:[function(e,t,n){(function(){var r,i,s;i=e("./parser"),s=e("./util"),r=function(){function e(){}var t,r;return e.cappingFreeLunch=0,e.cappingMinimumTimeInterval=0,e.options={withCredentials:!1,timeout:0},e.get=function(e,t,r){var s,o,a;if(o=+new Date,s=n.extend=function(e,t){var n,r;for(n in t)r=t[n],e[n]=r;return e},r||("function"==typeof t&&(r=t),a={}),a=s(this.options,t),this.totalCallsTimeout<o?(this.totalCalls=1,this.totalCallsTimeout=o+36e5):this.totalCalls++,this.cappingFreeLunch>=this.totalCalls)r(null);else{if(!(o-this.lastSuccessfullAd<this.cappingMinimumTimeInterval))return i.parse(e,a,function(e){return r(e)});r(null)}},r=s.storage,t=Object.defineProperty,["lastSuccessfullAd","totalCalls","totalCallsTimeout"].forEach(function(n){t(e,n,{get:function(){return r.getItem(n)},set:function(e){return r.setItem(n,e)},configurable:!1,enumerable:!0})}),null==e.totalCalls&&(e.totalCalls=0),null==e.totalCallsTimeout&&(e.totalCallsTimeout=0),e}(),t.exports=r}).call(this)},{"./parser":8,"./util":14}],4:[function(e,t,n){(function(){var e;e=function(){return function(){this.id=null,this.width=0,this.height=0,this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.companionClickThroughURLTemplate=null,this.trackingEvents={}}}(),t.exports=e}).call(this)},{}],5:[function(e,t,n){(function(){var e,n,r,i,s={}.hasOwnProperty,o=function(e,t){for(var n in t)s.call(t,n)&&(e[n]=t[n]);function r(){this.constructor=e}return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};e=function(){return function(){this.trackingEvents={}}}(),r=function(t){function n(){n.__super__.constructor.apply(this,arguments),this.type="linear",this.duration=0,this.skipDelay=null,this.mediaFiles=[],this.videoClickThroughURLTemplate=null,this.videoClickTrackingURLTemplates=[],this.videoCustomClickURLTemplates=[],this.adParameters=null}return o(n,e),n}(),i=function(t){function n(){return n.__super__.constructor.apply(this,arguments)}return o(n,e),n}(),n=function(t){function n(){this.type="companion",this.variations=[],this.videoClickTrackingURLTemplates=[]}return o(n,e),n}(),t.exports={VASTCreativeLinear:r,VASTCreativeNonLinear:i,VASTCreativeCompanion:n}}).call(this)},{}],6:[function(e,t,n){(function(){t.exports={client:e("./client"),tracker:e("./tracker"),parser:e("./parser"),util:e("./util")}}).call(this)},{"./client":3,"./parser":8,"./tracker":10,"./util":14}],7:[function(e,t,n){(function(){var e;e=function(){return function(){this.id=null,this.fileURL=null,this.deliveryType="progressive",this.mimeType=null,this.codec=null,this.bitrate=0,this.minBitrate=0,this.maxBitrate=0,this.width=0,this.height=0,this.apiFramework=null,this.scalable=null,this.maintainAspectRatio=null}}(),t.exports=e}).call(this)},{}],8:[function(e,t,n){(function(){var n,r,i,s,o,a,l,u,c,h,p=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1};r=e("./urlhandler"),c=e("./response"),i=e("./ad"),h=e("./util"),a=e("./creative").VASTCreativeLinear,o=e("./creative").VASTCreativeCompanion,l=e("./mediafile"),s=e("./companionad"),n=e("events").EventEmitter,u=function(){var e;function t(){}return e=[],t.addURLTemplateFilter=function(t){"function"==typeof t&&e.push(t)},t.removeURLTemplateFilter=function(){return e.pop()},t.countURLTemplateFilters=function(){return e.length},t.clearUrlTemplateFilters=function(){return e=[]},t.parse=function(e,t,n){return n||("function"==typeof t&&(n=t),t={}),this._parse(e,null,t,function(e,t){return n(t)})},t.vent=new n,t.track=function(e,t){return this.vent.emit("VAST-error",t),h.track(e,t)},t.on=function(e,t){return this.vent.on(e,t)},t.once=function(e,t){return this.vent.once(e,t)},t._parse=function(t,n,i,s){var o,a,l,u;for(s||("function"==typeof i&&(s=i),i={}),a=0,l=e.length;a<l;a++)o=e[a],t=o(t);return null==n&&(n=[]),n.push(t),r.get(t,i,(u=this,function(e,r){var o,a,l,h,f,d,m,v,g,y,k;if(null!=e)return s(e);if(f=new c,null==(null!=r?r.documentElement:void 0)||"VAST"!==r.documentElement.nodeName)return s();for(d=0,v=(y=r.documentElement.childNodes).length;d<v;d++)"Error"===(h=y[d]).nodeName&&f.errorURLTemplates.push(u.parseNodeText(h));for(m=0,g=(k=r.documentElement.childNodes).length;m<g;m++)"Ad"===(h=k[m]).nodeName&&(null!=(o=u.parseAdElement(h))?f.ads.push(o):u.track(f.errorURLTemplates,{ERRORCODE:101}));for(a=function(e){var t,n,r;if(null==e&&(e=!1),f){for(t=0,n=(r=f.ads).length;t<n;t++)if(null!=(o=r[t]).nextWrapperURL)return;return 0===f.ads.length&&(e||u.track(f.errorURLTemplates,{ERRORCODE:303}),f=null),s(null,f)}},l=f.ads.length;l--;)null!=(o=f.ads[l]).nextWrapperURL&&function(e){var r,s,o;n.length>=10||(o=e.nextWrapperURL,p.call(n,o)>=0)?(u.track(e.errorURLTemplates,{ERRORCODE:302}),f.ads.splice(f.ads.indexOf(e),1),a()):(0===e.nextWrapperURL.indexOf("//")?(s=location.protocol,e.nextWrapperURL=""+s+e.nextWrapperURL):-1===e.nextWrapperURL.indexOf("://")&&(r=t.slice(0,t.lastIndexOf("/")),e.nextWrapperURL=r+"/"+e.nextWrapperURL),u._parse(e.nextWrapperURL,n,i,function(t,n){var r,i,s,o,l,c,h,p,d,m,v,g,y,k,T,w,L,R;if(i=!1,null!=t)u.track(e.errorURLTemplates,{ERRORCODE:301}),f.ads.splice(f.ads.indexOf(e),1),i=!0;else if(null==n)u.track(e.errorURLTemplates,{ERRORCODE:303}),f.ads.splice(f.ads.indexOf(e),1),i=!0;else for(f.errorURLTemplates=f.errorURLTemplates.concat(n.errorURLTemplates),o=f.ads.indexOf(e),f.ads.splice(o,1),h=0,p=(T=n.ads).length;h<p;h++){if((l=T[h]).errorURLTemplates=e.errorURLTemplates.concat(l.errorURLTemplates),l.impressionURLTemplates=e.impressionURLTemplates.concat(l.impressionURLTemplates),null!=e.trackingEvents)for(g=0,d=(w=l.creatives).length;g<d;g++)if("linear"===(r=w[g]).type)for(y=0,m=(L=Object.keys(e.trackingEvents)).length;y<m;y++)s=L[y],(c=r.trackingEvents)[s]||(c[s]=[]),r.trackingEvents[s]=r.trackingEvents[s].concat(e.trackingEvents[s]);if(null!=e.videoClickTrackingURLTemplates)for(k=0,v=(R=l.creatives).length;k<v;k++)"linear"===(r=R[k]).type&&(r.videoClickTrackingURLTemplates=r.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates));f.ads.splice(o,0,l)}return delete e.nextWrapperURL,a(i)}))}(o);return a()}))},t.childByName=function(e,t){var n,r,i,s;for(r=0,i=(s=e.childNodes).length;r<i;r++)if((n=s[r]).nodeName===t)return n},t.childsByName=function(e,t){var n,r,i,s,o;for(r=[],i=0,s=(o=e.childNodes).length;i<s;i++)(n=o[i]).nodeName===t&&r.push(n);return r},t.parseAdElement=function(e){var t,n,r,i;for(n=0,r=(i=e.childNodes).length;n<r;n++){if((t=i[n]).id=e.getAttribute("id"),"Wrapper"===t.nodeName)return this.parseWrapperElement(t);if("InLine"===t.nodeName)return this.parseInLineElement(t)}},t.parseWrapperElement=function(e){var t,n,r,i,s,o,a;for(t=this.parseInLineElement(e),null!=(i=this.childByName(e,"VASTAdTagURI"))?t.nextWrapperURL=this.parseNodeText(i):null!=(i=this.childByName(e,"VASTAdTagURL"))&&(t.nextWrapperURL=this.parseNodeText(this.childByName(i,"URL"))),r=null,s=0,o=(a=t.creatives).length;s<o;s++)if("linear"===(n=a[s]).type){r=n;break}if(null!=r&&(null!=r.trackingEvents&&(t.trackingEvents=r.trackingEvents),null!=r.videoClickTrackingURLTemplates&&(t.videoClickTrackingURLTemplates=r.videoClickTrackingURLTemplates)),null!=t.nextWrapperURL)return t},t.parseInLineElement=function(e){var t,n,r,s,o,a,l,u,c,h,p,f,d;for((t=new i).id=e.id,o=0,u=(p=e.childNodes).length;o<u;o++)switch((s=p[o]).nodeName){case"Error":t.errorURLTemplates.push(this.parseNodeText(s));break;case"Impression":t.impressionURLTemplates.push(this.parseNodeText(s));break;case"Creatives":for(a=0,c=(f=this.childsByName(s,"Creative")).length;a<c;a++)for(l=0,h=(d=f[a].childNodes).length;l<h;l++)switch((r=d[l]).nodeName){case"Linear":(n=this.parseCreativeLinearElement(r))&&t.creatives.push(n);break;case"CompanionAds":(n=this.parseCompanionAd(r))&&t.creatives.push(n)}}return t},t.parseCreativeLinearElement=function(e){var t,n,r,i,s,o,u,c,h,p,f,d,m,v,g,y,k,T,w,L,R,x,E,C,U,A,N,b,_,O,D,I,M,S,B,j;if((r=new a).duration=this.parseDuration(this.parseNodeText(this.childByName(e,"Duration"))),-1===r.duration&&"Wrapper"!==e.parentNode.parentNode.parentNode.nodeName)return null;if(null==(m=e.getAttribute("skipoffset"))?r.skipDelay=null:"%"===m.charAt(m.length-1)?(f=parseInt(m,10),r.skipDelay=r.duration*(f/100)):r.skipDelay=this.parseDuration(m),null!=(k=this.childByName(e,"VideoClicks"))){for(r.videoClickThroughURLTemplate=this.parseNodeText(this.childByName(k,"ClickThrough")),w=0,E=(D=this.childsByName(k,"ClickTracking")).length;w<E;w++)n=D[w],r.videoClickTrackingURLTemplates.push(this.parseNodeText(n));for(L=0,C=(I=this.childsByName(k,"CustomClick")).length;L<C;L++)i=I[L],r.videoCustomClickURLTemplates.push(this.parseNodeText(i))}for(null!=(t=this.childByName(e,"AdParameters"))&&(r.adParameters=this.parseNodeText(t)),R=0,U=(M=this.childsByName(e,"TrackingEvents")).length;R<U;R++)for(g=M[R],x=0,A=(S=this.childsByName(g,"Tracking")).length;x<A;x++)if(s=(v=S[x]).getAttribute("event"),y=this.parseNodeText(v),null!=s&&null!=y){if("progress"===s){if(!(p=v.getAttribute("offset")))continue;s="%"===p.charAt(p.length-1)?"progress-"+p:"progress-"+Math.round(this.parseDuration(p))}null==(T=r.trackingEvents)[s]&&(T[s]=[]),r.trackingEvents[s].push(y)}for(_=0,N=(B=this.childsByName(e,"MediaFiles")).length;_<N;_++)for(h=B[_],O=0,b=(j=this.childsByName(h,"MediaFile")).length;O<b;O++)c=j[O],(u=new l).id=c.getAttribute("id"),u.fileURL=this.parseNodeText(c),u.deliveryType=c.getAttribute("delivery"),u.codec=c.getAttribute("codec"),u.mimeType=c.getAttribute("type"),u.apiFramework=c.getAttribute("apiFramework"),u.bitrate=parseInt(c.getAttribute("bitrate")||0),u.minBitrate=parseInt(c.getAttribute("minBitrate")||0),u.maxBitrate=parseInt(c.getAttribute("maxBitrate")||0),u.width=parseInt(c.getAttribute("width")||0),u.height=parseInt(c.getAttribute("height")||0),(d=c.getAttribute("scalable"))&&"string"==typeof d&&("true"===(d=d.toLowerCase())?u.scalable=!0:"false"===d&&(u.scalable=!1)),(o=c.getAttribute("maintainAspectRatio"))&&"string"==typeof o&&("true"===(o=o.toLowerCase())?u.maintainAspectRatio=!0:"false"===o&&(u.maintainAspectRatio=!1)),r.mediaFiles.push(u);return r},t.parseCompanionAd=function(e){var t,n,r,i,a,l,u,c,h,p,f,d,m,v,g,y,k,T,w,L,R,x,E,C,U,A,N,b,_;for(r=new o,d=0,y=(C=this.childsByName(e,"Companion")).length;d<y;d++){for(n=C[d],(t=new s).id=n.getAttribute("id")||null,t.width=n.getAttribute("width"),t.height=n.getAttribute("height"),m=0,k=(U=this.childsByName(n,"HTMLResource")).length;m<k;m++)a=U[m],t.type=a.getAttribute("creativeType")||"text/html",t.htmlResource=this.parseNodeText(a);for(v=0,T=(A=this.childsByName(n,"IFrameResource")).length;v<T;v++)l=A[v],t.type=l.getAttribute("creativeType")||0,t.iframeResource=this.parseNodeText(l);for(g=0,w=(N=this.childsByName(n,"StaticResource")).length;g<w;g++)u=N[g],t.type=u.getAttribute("creativeType")||0,t.staticResource=this.parseNodeText(u);for(x=0,L=(b=this.childsByName(n,"TrackingEvents")).length;x<L;x++)for(h=b[x],E=0,R=(_=this.childsByName(h,"Tracking")).length;E<R;E++)i=(c=_[E]).getAttribute("event"),p=this.parseNodeText(c),null!=i&&null!=p&&(null==(f=t.trackingEvents)[i]&&(f[i]=[]),t.trackingEvents[i].push(p));t.companionClickThroughURLTemplate=this.parseNodeText(this.childByName(n,"CompanionClickThrough")),r.variations.push(t)}return r},t.parseDuration=function(e){var t,n,r,i,s;return null==e?-1:3!==(t=e.split(":")).length?-1:(s=t[2].split("."),i=parseInt(s[0]),2===s.length&&(i+=parseFloat("0."+s[1])),r=parseInt(60*t[1]),n=parseInt(60*t[0]*60),isNaN(n||isNaN(r||isNaN(i||r>3600||i>60)))?-1:n+r+i)},t.parseNodeText=function(e){return e&&(e.textContent||e.text||"").trim()},t}(),t.exports=u}).call(this)},{"./ad":2,"./companionad":4,"./creative":5,"./mediafile":7,"./response":9,"./urlhandler":11,"./util":14,events:1}],9:[function(e,t,n){(function(){var e;e=function(){return function(){this.ads=[],this.errorURLTemplates=[]}}(),t.exports=e}).call(this)},{}],10:[function(e,t,n){(function(){var n,r,i,s,o,a={}.hasOwnProperty;r=e("./client"),o=e("./util"),i=e("./creative").VASTCreativeLinear,n=e("events").EventEmitter,s=function(e){function t(e,t){var n,s,o;for(n in this.ad=e,this.creative=t,this.muted=!1,this.impressed=!1,this.skipable=!1,this.skipDelayDefault=-1,this.trackingEvents={},this.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],o=this.creative.trackingEvents)s=o[n],this.trackingEvents[n]=s.slice(0);this.creative instanceof i?(this.setDuration(this.creative.duration),this.skipDelay=this.creative.skipDelay,this.linear=!0,this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates):(this.skipDelay=-1,this.linear=!1),this.on("start",function(){r.lastSuccessfullAd=+new Date})}return function(e,t){for(var n in t)a.call(t,n)&&(e[n]=t[n]);function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype}(t,n),t.prototype.setDuration=function(e){return this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}},t.prototype.setProgress=function(e){var t,n,r,i,s,o,a,l,u;if(-1===(s=null===this.skipDelay?this.skipDelayDefault:this.skipDelay)||this.skipable||(s>e?this.emit("skip-countdown",s-e):(this.skipable=!0,this.emit("skip-countdown",0))),this.linear&&this.assetDuration>0){if(n=[],e>0)for(i in n.push("start"),r=Math.round(e/this.assetDuration*100),n.push("progress-"+r+"%"),n.push("progress-"+Math.round(e)),u=this.quartiles)(o=u[i])<=e&&e<=o+1&&n.push(i);for(a=0,l=n.length;a<l;a++)t=n[a],this.track(t,!0);e<this.progress&&this.track("rewind")}return this.progress=e},t.prototype.setMuted=function(e){return this.muted!==e&&this.track(e?"mute":"unmute"),this.muted=e},t.prototype.setPaused=function(e){return this.paused!==e&&this.track(e?"pause":"resume"),this.paused=e},t.prototype.setFullscreen=function(e){return this.fullscreen!==e&&this.track(e?"fullscreen":"exitFullscreen"),this.fullscreen=e},t.prototype.setSkipDelay=function(e){if("number"==typeof e)return this.skipDelay=e},t.prototype.load=function(){if(!this.impressed)return this.impressed=!0,this.trackURLs(this.ad.impressionURLTemplates),this.track("creativeView")},t.prototype.errorWithCode=function(e){return this.trackURLs(this.ad.errorURLTemplates,{ERRORCODE:e})},t.prototype.complete=function(){return this.track("complete")},t.prototype.close=function(){return this.track(this.linear?"closeLinear":"close")},t.prototype.stop=function(){},t.prototype.skip=function(){return this.track("skip"),this.trackingEvents=[]},t.prototype.click=function(){var e,t,n;if((null!=(n=this.clickTrackingURLTemplates)?n.length:void 0)&&this.trackURLs(this.clickTrackingURLTemplates),null!=this.clickThroughURLTemplate)return this.linear&&(t={CONTENTPLAYHEAD:this.progressFormated()}),e=o.resolveURLTemplates([this.clickThroughURLTemplate],t)[0],this.emit("clickthrough",e)},t.prototype.track=function(e,t){var n,r;null==t&&(t=!1),"closeLinear"===e&&null==this.trackingEvents[e]&&null!=this.trackingEvents.close&&(e="close"),r=this.trackingEvents[e],n=this.emitAlwaysEvents.indexOf(e),null!=r?(this.emit(e,""),this.trackURLs(r)):-1!==n&&this.emit(e,""),!0===t&&(delete this.trackingEvents[e],n>-1&&this.emitAlwaysEvents.splice(n,1))},t.prototype.trackURLs=function(e,t){return null==t&&(t={}),this.linear&&(t.CONTENTPLAYHEAD=this.progressFormated()),o.track(e,t)},t.prototype.progressFormated=function(){var e,t,n,r;return(e=(r=parseInt(this.progress))/3600).length<2&&(e="0"+e),(t=r/60%60).length<2&&(t="0"+t),(n=r%60).length<2&&(n="0"+t),e+":"+t+":"+n+"."+parseInt(100*(this.progress-r))},t}(),t.exports=s}).call(this)},{"./client":3,"./creative":5,"./util":14,events:1}],11:[function(e,t,n){(function(){var n,r,i;i=e("./urlhandlers/xmlhttprequest"),r=e("./urlhandlers/flash"),n=function(){function t(){}return t.get=function(t,n,s){return s||("function"==typeof n&&(s=n),n={}),n.urlhandler&&n.urlhandler.supported()?n.urlhandler.get(t,n,s):"undefined"==typeof window||null===window?e("./urlhandlers/node").get(t,n,s):i.supported()?i.get(t,n,s):r.supported()?r.get(t,n,s):s()},t}(),t.exports=n}).call(this)},{"./urlhandlers/flash":12,"./urlhandlers/xmlhttprequest":13}],12:[function(e,t,n){(function(){var e;e=function(){function e(){}return e.xdr=function(){var e;return window.XDomainRequest&&(e=new XDomainRequest),e},e.supported=function(){return!!this.xdr()},e.get=function(e,t,n){var r,i;return(i="function"==typeof window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLDOM"):void 0)?(i.async=!1,(r=this.xdr()).open("GET",e),r.timeout=t.timeout||0,r.withCredentials=t.withCredentials||!1,r.send(),r.onprogress=function(){},r.onload=function(){return i.loadXML(r.responseText),n(null,i)}):n()},e}(),t.exports=e}).call(this)},{}],13:[function(e,t,n){(function(){var e;e=function(){function e(){}return e.xhr=function(){var e;if("withCredentials"in(e=new window.XMLHttpRequest))return e},e.supported=function(){return!!this.xhr()},e.get=function(e,t,n){var r;if("https:"===window.location.protocol&&0===e.indexOf("http://"))return n(new Error("Cannot go from HTTPS to HTTP."));try{return(r=this.xhr()).open("GET",e),r.timeout=t.timeout||0,r.withCredentials=t.withCredentials||!1,r.send(),r.onreadystatechange=function(){if(4===r.readyState)return n(null,r.responseXML)}}catch(e){return n()}},e}(),t.exports=e}).call(this)},{}],14:[function(e,t,n){(function(){var e;e=function(){function e(){}return e.track=function(e,t){var n,r,i,s,o,a;for(a=[],s=0,o=(r=this.resolveURLTemplates(e,t)).length;s<o;s++)n=r[s],"undefined"!=typeof window&&null!==window&&(i=new Image,a.push(i.src=n));return a},e.resolveURLTemplates=function(e,t){var n,r,i,s,o,a,l,u;n=[],null==t&&(t={}),"CACHEBUSTING"in t||(t.CACHEBUSTING=Math.round(1e10*Math.random())),t.random=t.CACHEBUSTING;for(l=0,u=e.length;l<u;l++)if(o=e[l]){for(r in t)a=t[r],i="["+r+"]",s="%%"+r+"%%",o=(o=o.replace(i,a)).replace(s,a);n.push(o)}return n},e.storage=function(){var e,t;try{t="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){e,t=null}return(null==t||function(e){try{if("__VASTUtil__",e.setItem("__VASTUtil__","__VASTUtil__"),"__VASTUtil__"!==e.getItem("__VASTUtil__"))return!0}catch(e){return e,!0}return!1}(t))&&(e={},t={length:0,getItem:function(t){return e[t]},setItem:function(t,n){e[t]=n,this.length=Object.keys(e).length},removeItem:function(t){delete e[t],this.length=Object.keys(e).length},clear:function(){e={},this.length=0}}),t}(),e}(),t.exports=e}).call(this)},{}],15:[function(e,t,n){var r=e("vast-client"),i=["application/x-mpegurl","video/webm","video/mp4"];t.exports={init:function(e,t,n){if("transparent"!=t.conf.wmode)throw new Error("The player must have wmove = transparent for video clicks to work in IE.");if(!t.conf.playlist||!t.conf.playlist.length)throw new Error("The player must have a playlist configured.");var r=this;this.loadPreroll(e,n,function(n){if(n){if(n.swf)return t.trigger("vpaid_swf",[n.swf]);if(n.js)return t.trigger("vpaid_js",[n.js]);if(n.video){r.attachEvents(e,t);var i=!1;t.one("resume load",function(e){if(!i)return i=!0,e.preventDefault(),setTimeout(function(){var e=t.conf.playlist.slice(0);e.unshift(n.video),t.setPlaylist(e),t.play(0)},0),!1})}}})},attachEvents:function(e,t,n){var r=!1,i=!1,s=!1,o=!1;(n=n||{}).adjustable&&t.on("beforeseek",function(e){t.video.ad&&e.preventDefault()});var a=function(){n.adjustable||t.disable(!0)},l=function(){n.adjustable||t.disable(!1)};if(flowplayer.support.inlineVideo){var u=e.querySelectorAll(".fp-player")[0],c=function(e){("fp-ui"==e.target.className||"fp-engine"==e.target.className)&&t.video.ad&&t.playing&&(u.removeEventListener("click",c,!0),t.video.tracker.click())};u&&u.addEventListener("click",c,!0)}flowplayer.support.inlineVideo&&t.on("pause",function(){t.video.ad&&l()}),t.on("unload",function(){l()}),t.on("progress",function(t,n,s){if(n.video.ad&&n.playing){o=!0,a(),n.video.tracker.setProgress(s);var l=e.querySelectorAll(".fp-title")[0],u=e.querySelectorAll(".fp-header")[0];if(l){if(!i){i=!0;var c=function(){n.video.skip&&n.video.time>=n.video.skip&&(r=!0,n.video.tracker.skip(),n.play(1))};l.onclick=c,u&&(u.onclick=c)}n.video.skip?n.video.skip&&s>=n.video.skip?l.innerHTML="Advertisement: <strong>Skip Ad »</strong>":l.innerHTML="Advertisement: Skippable in "+Math.round(n.video.skip-s)+" seconds...":l.innerHTML="Advertisement: Ends in "+Math.round(n.video.duration-s)+" seconds..."}}}),t.on("finish.vast_complete",function(){t.video.ad&&(t.off("finish.vast_complete"),r||t.video.tracker.complete())}),t.on("ready",function(){if(t.video.ad)return t.video.tracker.load();l(),!s&&o&&(s=!0,!0!==n.keepPreroll&&t.removePlaylistItem(0))})},loadPreroll:function(e,t,n,s){var o=!1,a=setTimeout(function(){o=!0,n()},s||5e3);r.client.get(t,function(t){if(!o){var s=[];if(clearTimeout(a),t&&t.ads.forEach(function(t){t.creatives.some(function(n){if("linear"==n.type){var o=new r.tracker(t,n),a={tracker:o,skip:n.skipDelay,title:"Advertisement",ad:!0,sources:[]};a.tracker.on("clickthrough",function(e){window.open(e)});var l={},u={};return n.mediaFiles.forEach(function(t){if("application/javascript"==t.mimeType)return s.push({js:{width:t.width,height:t.height,src:t.fileURL,parameters:n.adParameters,tracker:o}});if("application/x-shockwave-flash"==t.mimeType)return s.push({swf:{src:t.fileURL,width:t.width,height:t.height,parameters:n.adParameters,tracker:o}});if(i.indexOf(t.mimeType)>-1){var r={width:t.width,height:t.height,seconds:n.duration,src:t.fileURL};(!u[t.mimeType]||u[t.mimeType].width>t.width)&&(u[t.mimeType]=r),e.offsetWidth>=t.width&&(!l[t.mimeType]||t.width>l[t.mimeType].width)&&(l[t.mimeType]=r)}}),i.forEach(function(e){var t=l[e]||u[e];t&&a.sources.push({type:e,seconds:t.seconds,width:t.width,height:t.height,src:t.src})}),a.sources.length>0&&s.push({clip:a}),!0}})}),s[0]){if(s[0].swf)return n({type:"swf",swf:s[0].swf});if(s[0].js)return n({type:"js",js:s[0].js});if(s[0].clip)return n({type:"video",video:s[0].clip})}n(null)}})}}},{"vast-client":6}]},{},[15]);
},{}]},{},[1]);