You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 lines
103 KiB
JavaScript

!function(a,b){"use strict";"function"==typeof define&&define.amd?(b(a.ns_=a.ns_||{}),define('nyt_comscore_streaming',[],function(){return a.ns_})):"object"==typeof module&&module.exports?module.exports=b({}):b(a.ns_=a.ns_||{})}(this,function(a){"use strict";a.ns_=a;var b=b||{};b.indexOf=function(a,b){var c=-1;return this.forEach(b,function(b,d){b==a&&(c=d)}),c},b.forEach=function(a,b,c){try{if("function"==typeof b)if(c="undefined"!=typeof c?c:null,"number"!=typeof a.length||"undefined"==typeof a[0]){var d="undefined"!=typeof a.__proto__;for(var e in a)a.hasOwnProperty(e)&&(!d||d&&"undefined"==typeof a.__proto__[e])&&"function"!=typeof a[e]&&b.call(c,a[e],e)}else for(var f=0,g=a.length;f<g;f++)b.call(c,a[f],f)}catch(h){}};var b=b||{};b.parseBoolean=function(a,b){return b=b||!1,a?"0"!=a:b},b.parseInteger=function(a,b){return null==a||isNaN(a)?b||0:parseInt(a)},b.parseLong=function(a,b){var c=Number(a);return null==a||isNaN(c)?b||0:c},b.toString=function(a){if("undefined"==typeof a)return"undefined";if("string"==typeof a)return a;if(a instanceof Array)return a.join(",");var b="";for(var c in a)a.hasOwnProperty(c)&&(b+=c+":"+a[c]+";");return b||a.toString()};var b=b||{};b.filter=function(a,b){var c={};for(var d in b)b.hasOwnProperty(d)&&a(b[d])&&(c[d]=b[d]);return c},b.extend=function(a){var b,c=arguments.length;a=a||{};for(var d=1;d<c;d++)if(b=arguments[d])for(var e in b)b.hasOwnProperty(e)&&(a[e]=b[e]);return a};var b=b||{};b.cloneObject=function(a){if(null==a||"object"!=typeof a)return a;var b=function(){function a(){}function b(b){return"object"==typeof b?(a.prototype=b,new a):b}function c(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}function d(){this.copiedObjects=[];var a=this;this.recursiveDeepCopy=function(b){return a.deepCopy(b)},this.depth=0}function e(a,b){var c=new d;return b&&(c.maxDepth=b),c.deepCopy(a)}function f(a){return"undefined"!=typeof window&&window&&window.Node?a instanceof Node:"undefined"!=typeof document&&a===document||"number"==typeof a.nodeType&&a.attributes&&a.childNodes&&a.cloneNode}var g=[];return c.prototype={constructor:c,canCopy:function(){return!1},create:function(a){},populate:function(a,b,c){}},d.prototype={constructor:d,maxDepth:256,cacheResult:function(a,b){this.copiedObjects.push([a,b])},getCachedResult:function(a){for(var b=this.copiedObjects,c=b.length,d=0;d<c;d++)if(b[d][0]===a)return b[d][1]},deepCopy:function(a){if(null===a)return null;if("object"!=typeof a)return a;var b=this.getCachedResult(a);if(b)return b;for(var c=0;c<g.length;c++){var d=g[c];if(d.canCopy(a))return this.applyDeepCopier(d,a)}throw new Error("Unable to clone the following object "+a)},applyDeepCopier:function(a,b){var c=a.create(b);if(this.cacheResult(b,c),this.depth++,this.depth>this.maxDepth)throw new Error("Maximum recursion depth exceeded.");return a.populate(this.recursiveDeepCopy,b,c),this.depth--,c}},e.DeepCopier=c,e.deepCopiers=g,e.register=function(a){a instanceof c||(a=new c(a)),g.unshift(a)},e.register({canCopy:function(){return!0},create:function(a){return a instanceof a.constructor?b(a.constructor.prototype):{}},populate:function(a,b,c){for(var d in b)b.hasOwnProperty(d)&&(c[d]=a(b[d]));return c}}),e.register({canCopy:function(a){return a instanceof Array},create:function(a){return new a.constructor},populate:function(a,b,c){for(var d=0;d<b.length;d++)c.push(a(b[d]));return c}}),e.register({canCopy:function(a){return a instanceof Date},create:function(a){return new Date(a)}}),e.register({canCopy:function(a){return f(a)},create:function(a){return"undefined"!=typeof document&&a===document?document:a.cloneNode(!1)},populate:function(a,b,c){if("undefined"!=typeof document&&b===document)return document;if(b.childNodes&&b.childNodes.length)for(var d=0;d<b.childNodes.length;d++){var e=a(b.childNodes[d]);c.appendChild(e)}}}),{deepCopy:e}}();return b.deepCopy(a)};var b=b||{};b.getNamespace=function(){return a.ns_||a},b.uid=function(){var a=1;return function(){return+new Date+"_"+a++}}(),b.isEmpty=function(a){return void 0===a||null===a||""===a||a instanceof Array&&0===a.length},b.isNotEmpty=funct
n.incrementAssetLoadCounter(),n.isAssetStarted()&&d&&m.incrementPlayCounter(),d&&(m.setPlaySequenceCounter(0),n.setPlaybackSessionLooping(!0)),!b.exists(c.ns_st_tp)&&b.exists(c.ns_st_ad)&&b.isNotEmpty(c.ns_st_ad)&&"0"!==c.ns_st_ad&&n.setInternalLabel("ns_st_tp","1")}}),c()}return a.resetPlaybackSession=function(a,b,c){for(var d=b.getAsset(),e=b.getLabels(),f={},g=0;c&&g<c.length;g++)e.hasOwnProperty(c[g])&&(f[c[g]]=e[c[g]]);a.getPlaybackSession().setLabels(f),m.resetAsset(d,a.getPlaybackSession().getAsset(),c)},a}(),o=function(){return function(a){function c(){e=1}function d(c){f=b.extend({},c);var d=a.getStaCore().getLiveEndpointURL();if(a.getAppCore()){if(a.getStaCore().isProperlyInitialized()){var e=a.getStaCore().getExports().et;if("function"==typeof a.getAppCore().getMeasurementDispatcher){var g=a.getAppCore().getMeasurementDispatcher();g.send(e.HIDDEN,c,d)}else{var h=a.getStaCore().getExports().am,i=h.newApplicationMeasurement(a.getAppCore(),e.HIDDEN,c,d);a.getAppCore().getQueue().offer(i)}}}else d&&a.getStaCore().getPlatformAPI().httpGet(a.getStaCore().prepareUrl(d,c))}var e,f,g=this,h=[];b.extend(this,{newEvent:function(a){for(var b=0;b<h.length;++b)h[b](a.eventLabels);d(a.eventLabels),a.eventType!=i.HEARTBEAT&&g.incrementEventCounter()},addMeasurementListener:function(a){"function"==typeof a&&h.push(a)},removeMeasurementListener:function(a){for(var b=NaN,c=0;c<h.length;++c)if(h[c]==a){b=c;break}isNaN(b)||h.splice(b,1)},getEventCounter:function(){return e},incrementEventCounter:function(){e++},setEventCounter:function(a){e=a},getMeasurementSnapshot:function(){return f}}),c()}}(),p=function(){return function(a){function c(){g=0,h=0}function d(){h++;var c={},d=b.fixEventTime(c);c.ns_st_hc=a.getHeartbeat().getCount()+"";var e=a.getStaCore().createLabels(i.HEARTBEAT,c,d);a.getPlaybackSession().getAsset().updateIndependentLabels(e.eventLabels),a.getEventManager().newEvent(e),g=0,j.resume()}function e(){null!=f&&(a.getStaCore().getPlatformAPI().clearTimeout(f),f=null)}var f,g,h,j=this,k=l.DEFAULT_HEARTBEAT_INTERVAL;b.extend(this,{getCount:function(){return h},setIntervals:function(a){k=a},getInterval:function(a){var b=0;if(null!=k)for(var c=0;c<k.length;c++){var d=k[c],e=d.playingtime;if(!e||a<e){b=d.interval;break}}return b},getIntervals:function(){return k},resume:function(){e();var b=j.getInterval(a.getPlaybackSession().getAsset().getPlaybackTime()+(+new Date-a.getPlaybackSession().getAsset().getPlaybackTimestamp()));if(b>0){var c=g>0?g:b;f=a.getStaCore().getPlatformAPI().setTimeout(d,c)}g=0},pause:function(){e();var b=j.getInterval(a.getPlaybackSession().getAsset().getPlaybackTime()+(+new Date-a.getPlaybackSession().getAsset().getPlaybackTimestamp()));g=b-(a.getPlaybackSession().getAsset().getPlaybackTime()+(+new Date-a.getPlaybackSession().getAsset().getPlaybackTimestamp()))%b}}),c()}}(),q=function(){return function(a){function c(){}function d(){var c={},d=b.fixEventTime(c);a.getStaCore().newPseudoEvent(i.KEEPALIVE,d,c),g.start()}function e(){null!=f&&(a.getStaCore().getPlatformAPI().clearTimeout(f),f=null)}var f,g=this,h=l.DEFAULT_KEEP_ALIVE_INTERVAL;b.extend(g,{start:function(){e(),f=a.getStaCore().getPlatformAPI().setTimeout(d,h)},stop:e,setInterval:function(a){h=a},getInterval:function(){return h}}),c()}}(),r=function(){return function(a){function c(){f=j.IDLE,e=null,d=NaN}var d,e,f,g=this;b.extend(g,{eventTypeToState:function(a){if(f==j.IDLE){if(a==i.PLAY)return j.PLAYING;if(a==i.SEEK_START)return j.SEEKING_BEFORE_PLAYBACK;if(a==i.BUFFER)return j.BUFFERING_BEFORE_PLAYBACK}else if(f==j.PLAYBACK_NOT_STARTED){if(a==i.PLAY)return j.PLAYING;if(a==i.SEEK_START)return j.SEEKING_BEFORE_PLAYBACK;if(a==i.BUFFER)return j.BUFFERING_BEFORE_PLAYBACK;if(a==i.END||a==i.AD_SKIP)return j.IDLE}else if(f==j.PLAYING){if(a==i.END||a==i.AD_SKIP)return j.IDLE;if(a==i.BUFFER)return j.BUFFERING_DURING_PLAYBACK;if(a==i.PAUSE)return j.PAUSED;if(a==i.SEEK_START)return j.SEEKING_DURING_PLAYBACK}else if(f==j.PAUSED){if(a==i.END||a==i.AD_SKIP)return j.IDLE;if(a==i.BUFFER)return j.BUFFERING_DURING_PAUSE;if(a==i.PLAY)return j.PLAYING;if(a==i
a.getPlaybackSession().addBufferingTime(b),a.getPlaybackSession().getAsset().addBufferingTime(b),a.getPlaybackSession().getAsset().incrementPlayCounter(),a.getPlaybackSession().setPlaybackTimestamp(b),a.getPlaybackSession().getAsset().setPlaybackTimestamp(b),a.getPlaybackSession().getAsset().addElapsedTime(b),a.getPlaybackSession().getAsset().setElapsedTimestamp(b),a.getPlaybackSession().getAsset().setPlaybackStartPosition(d),a.getHeartbeat().resume(),a.getKeepAlive().start();var e=a.getStaCore().createLabels(i.PLAY,c,b);a.getPlaybackSession().getAsset().updateDeltaLabels(e.eventLabels),a.getPlaybackSession().getAsset().updateIndependentLabels(e.eventLabels),a.getEventManager().newEvent(e)}})}}(),A=function(){return function(a){var c=this;b.extend(c,{onEndOrAdSkip:function(c,d){a.getPlaybackSession().getAsset().isSeeking()&&a.getPlaybackSession().getAsset().isCollectingSeekingTime()&&(a.getPlaybackSession().getAsset().setSeekingTimeBeforeEnd(c-a.getPlaybackSession().getAsset().getSeekingTimestamp()),a.getPlaybackSession().getAsset().setCollectingSeekingTime(!1)),a.getPlaybackSession().storeAssetPlaybackCounters(),a.getPlaybackSession().getAsset().resetAssetLifecycleLabels(),a.getPlaybackSession().getAsset().setPlaybackStarted(!1),d.hasOwnProperty("ns_st_pe")&&b.parseBoolean(d.ns_st_pe,!1)&&a.getStaCore().resetPlaybackSession()},onSeekStart:function(b,c){var d=parseInt(c.ns_st_po);a.getPlaybackSession().getAsset().isSeeking()?a.getPlaybackSession().getAsset().setSeekingTimestamp(b):a.getPlaybackSession().getAsset().incrementSeeks(),a.getPlaybackSession().getAsset().isSeeking()||(a.getPlaybackSession().getAsset().setSeeking(!0),a.getPlaybackSession().getAsset().setCollectingSeekingTime(!0),a.getPlaybackSession().getAsset().setSeekStartPosition(d),a.getPlaybackSession().getAsset().setSeekingTimestamp(b))},onPlay:function(b,c){var d=parseInt(c.ns_st_po);a.getPlaybackSession().getAsset().isSeeking()&&(a.getPlaybackSession().getAsset().addSeekingAmount(d),a.getPlaybackSession().getAsset().setSeeking(!1)),a.getPlaybackSession().setPlaybackSessionStarted(!0),(a.getPlaybackSession().getAsset().isPlaybackSessionLooping()||0==a.getPlaybackSession().getPlaybackCounter())&&(a.getPlaybackSession().incrementPlaybackCounter(),a.getPlaybackSession().getAsset().setPlaybackSessionLooping(!1)),a.getPlaybackSession().incrementPlaySequenceCounter(),a.getPlaybackSession().getAsset().setPlaybackStarted(!0),a.getPlaybackSession().getAsset().incrementSegmentPlaybackCounter(),(0==a.getPlaybackSession().getAsset().getLowestPartNumberPlayed()||a.getPlaybackSession().getAsset().getPartNumber()<=a.getPlaybackSession().getAsset().getLowestPartNumberPlayed())&&(a.getPlaybackSession().getAsset().setLowestPartNumberPlayed(a.getPlaybackSession().getAsset().getPartNumber()),a.getPlaybackSession().getAsset().incrementAssetPlaybackCounter(),a.getPlaybackSession().getAsset().setPlaySequenceCounter(0),a.getPlaybackSession().getAsset().resetAssetPlaybackIntervals()),a.getPlaybackSession().getAsset().incrementPlaySequenceCounter(),a.getPlaybackSession().getAsset().incrementPlayCounter(),a.getPlaybackSession().setPlaybackTimestamp(b),a.getPlaybackSession().getAsset().setPlaybackTimestamp(b),a.getPlaybackSession().getAsset().setElapsedTimestamp(b),a.getPlaybackSession().getAsset().setPlaybackStartPosition(d),a.getStaCore().isLoadingTimeSent()||(c.ns_st_lt=a.getStaCore().getLoadTimeOffset()+b-a.getStaCore().getInitTimestamp()+"",a.getStaCore().setLoadingTimeSent(!0)),a.getHeartbeat().resume(),a.getKeepAlive().start();var e=a.getStaCore().createLabels(i.PLAY,c,b);a.getPlaybackSession().getAsset().updateDeltaLabels(e.eventLabels),a.getPlaybackSession().getAsset().updateIndependentLabels(e.eventLabels),a.getEventManager().newEvent(e)},onBuffer:function(){a.getPlaybackSession().setBufferingTimestamp(eventTimestamp),a.getPlaybackSession().getAsset().setBufferingTimestamp(eventTimestamp)}})}}(),B=function(){return function(a){var c=this;b.extend(c,{onEndOrAdSkip:function(c,d){var e=parseInt(d.ns_st_po);a.getStaCore().resetHeartbeat(),a.getKeepAlive().stop(),a.getPlayback
a==i.PLAY||a==i.PAUSE||a==i.BUFFER||a==i.END||a==i.SEEK_START||a==i.AD_SKIP||a==i.BUFFER_STOP?f.newEvent(a,e,c):f.newPseudoEvent(a,e,c)}}function e(){h&&f.getStaSM().getStateMachine().getCurrentState()!=j.IDLE&&g.notifyEnd()}var f,g=this,h=!0;b.extend(this,{isProperlyInitialized:function(){return f.isProperlyInitialized()},reset:function(a){d(i.END);var b=f;b.getStaSM().getKeepAlive().stop(),b.getStaSM().getHeartbeat().pause(),f=new F(b.getConfiguration()),n.resetPlaybackSession(f.getStaSM(),b.getStaSM().getPlaybackSession(),a)},setPauseOnBufferingInterval:function(a){f.setPauseOnBufferingInterval(a)},getPauseOnBufferingInterval:function(){return f.getPauseOnBufferingInterval()},setKeepAliveInterval:function(a){f.getStaSM().getKeepAlive().setInterval(a)},getKeepAliveInterval:function(){return f.getStaSM().getKeepAlive().getInterval()},setHeartbeatIntervals:function(a){f.getStaSM().getHeartbeat().setIntervals(a)},notifyPlay:function(a,b){f.getStaSM().getLogging().apiCall("notifyPlay",a,b),d(i.PLAY,a,b)},notifyPause:function(a,b){f.getStaSM().getLogging().apiCall("notifyPause",a,b),d(i.PAUSE,a,b)},notifyEnd:function(a,b){f.getStaSM().getLogging().apiCall("notifyEnd",a,b),d(i.END,a,b)},notifyBufferStart:function(a,b){f.getStaSM().getLogging().apiCall("notifyBufferStart",a,b),d(i.BUFFER,a,b)},notifyBufferStop:function(a,b){f.getStaSM().getLogging().apiCall("notifyBufferStop",a,b),d(i.BUFFER_STOP,a,b)},notifyLoad:function(a,b){f.getStaSM().getLogging().apiCall("notifyLoad",a,b),d(i.LOAD,a,b)},notifyEngage:function(a,b){f.getStaSM().getLogging().apiCall("notifyEngage",a,b),d(i.ENGAGE,a,b)},notifySeekStart:function(a,b){f.getStaSM().getLogging().apiCall("notifySeekStart",a,b),d(i.SEEK_START,a,b)},notifySkipAd:function(a,b){f.getStaSM().getLogging().apiCall("notifySkipAd",a,b),d(i.AD_SKIP,a,b)},notifyCallToAction:function(a,b){f.getStaSM().getLogging().apiCall("notifyCallToAction",a,b),d(i.CTA,a,b)},notifyError:function(a,b){f.getStaSM().getLogging().apiCall("notifyError",a,b),d(i.ERROR,a,b)},notifyTransferPlayback:function(a,b){f.getStaSM().getLogging().apiCall("notifyTransferPlayback",a,b),d(i.TRANSFER,a,b)},notifyDrmFail:function(a,b){f.getStaSM().getLogging().apiCall("notifyDrmFail",a,b),d(i.DRM_FAILED,a,b)},notifyDrmApprove:function(a,b){f.getStaSM().getLogging().apiCall("notifyDrmApprove",a,b),d(i.DRM_APPROVED,a,b)},notifyDrmDeny:function(a,b){f.getStaSM().getLogging().apiCall("notifyDrmDeny",a,b),d(i.DRM_DENIED,a,b)},notifyChangeBitrate:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeBitrate",a,b,c),null!=a){var e=c||{};e.ns_st_br=a+"",d(i.BIT_RATE,e,b)}},notifyChangePlaybackRate:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangePlaybackRate",a,b,c),null!=a){var e=c||{};e.ns_st_rt=a+"",d(i.PLAYBACK_RATE,e,b)}},notifyChangeVolume:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeVolume",a,b,c),null!=a){var e=c||{};e.ns_st_vo=a+"",d(i.VOLUME,e,b)}},notifyChangeWindowState:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeWindowState",a,b,c),null!=a){var e=c||{};e.ns_st_ws=a+"",d(i.WINDOW_STATE,e,b)}},notifyChangeAudioTrack:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeAudioTrack",a,b,c),null!=a){var e=c||{};e.ns_st_at=a+"",d(i.AUDIO,e,b)}},notifyChangeVideoTrack:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeVideoTrack",a,b,c),null!=a){var e=c||{};e.ns_st_vt=a+"",d(i.VIDEO,e,b)}},notifyChangeSubtitleTrack:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeSubtitleTrack",a,b,c),null!=a){var e=c||{};e.ns_st_tt=a+"",d(i.SUBS,e,b)}},notifyChangeCdn:function(a,b,c){if(f.getStaSM().getLogging().apiCall("notifyChangeCdn",a,b,c),null!=a){var e=c||{};e.ns_st_cdn=a+"",d(i.CDN,e,b)}},notifyCustomEvent:function(a,b){f.getStaSM().getLogging().apiCall("notifyCustomEvent",a,b),d(i.CUSTOM,a,b)},getLabels:function(){return f.getLabels()},getState:function(){return f.getStaSM().getStateMachine().getCurrentState()},setLabels:function(a){f.setLabels(a)},getLabel:function(a){return f.getLabel(a)},setLabel:function(a,b){f.setL