@flowplayer/player 3.25.0 → 3.26.0-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +2 -2
- package/package.json +1 -1
- package/plugins/ads.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/rts.d.ts +12 -7
- package/plugins/rts.js +1 -1
- package/plugins/ssai.js +1 -1
package/package.json
CHANGED
package/plugins/ads.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* https://github.com/lancedikson/bowser
|
|
5
5
|
* MIT License | (c) Dustin Diaz 2012-2015
|
|
6
6
|
* MIT License | (c) Denis Demchenko 2015-2019
|
|
7
|
-
*/const ye=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return ce}static get ENGINE_MAP(){return pe}static get OS_MAP(){return he}static get PLATFORMS_MAP(){return ue}}.parse(window.navigator.userAgent),{platform:Ae,os:be,browser:we}=ye,Ee=e=>e&&e.toLowerCase();var Se={rnd:Math.random().toString(36).substr(2,32),os:Ee(be.name+(be.versionName?" "+be.versionName:"")),device:Ee(Ae.type),browser:Ee(we.name),browser_version:(we&&we.version?we.version:"unknown").split(".").shift(),plugin_version:"3.25.0"};const Te="https://fp-eu-w1-aai.flowplayer.com/in",Le="POST",Oe=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],Re=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Me=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],ke=S("ads/analytics"),Pe=RequestQueue.of(),De=(...e)=>Object.assign({},...e);class Analytics{static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,De(e.metadata,t,{player_version:"3.25.0"})),e}constructor(e,t={}){this.emitter=e,this.metadata=De(Se,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),ke(this),this.wireup()}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,i=De(this.metadata,{event_type:e},s),r=Analytics.pluck_valid_keys(this,i),a=Analytics.ensure_required_keys(this,r);if(ke(`Event[${e}]`,{payload:r,observation:s}),a.length)return ke(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${a}`,r);RequestQueue.rpush(Pe,[Te,Le,r])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const Ie=S("ads/controller"),Ne={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends class EventBus{constructor(e=document.createElement("div"),t=[]){this._bus=e,this._listeners=t}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(e,t){const s=new CustomEvent(e,{detail:t||{}});this._bus.dispatchEvent(s)}on(e,t){this._listeners.push([e,t]),this._bus.addEventListener(e,t,{passive:!0})}once(e,t){this._bus.addEventListener(e,t,{once:!0})}removeListener(e,t){this._bus.removeEventListener(e,t)}}{constructor(e={}){var t;super(),this.adapter=function(e,t){return e.adapter?new e.adapter(t):new IMA(t)}(e,this),this.opts=Object.assign(Object.assign({},Ne),e),this.analytics=(t=this,Analytics.of(t,{required_keys:Re,optional_keys:Me,events:Oe})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(e.parameters||{}),this.wireup(),this.content_processing_src=!1}reset(){return this.removeAllListeners(),this.wireup(),this.analytics&&this.analytics.wireup(),this._state.reset(),this.adapter.reset(),this}destroy(){this.removeAllListeners(),this.analytics&&this.analytics.destroy(),this.adapter&&this.adapter.destroy();this.analytics=void 0,this.opts=void 0,this.adapter=void 0,this._state=void 0,this._schedule=void 0,this._lastAd=void 0,this._macros=void 0}stop(){this.adapter&&this.adapter.stop()}onContentNewSrc(){this._state.reset(),this.adapter.destroyManager(),this.adapter.contentComplete()}wireup(){const e=()=>{var e,t;null===(e=this.videoTag)||void 0===e||e.setState("ad-paused",!1),null===(t=this.videoTag)||void 0===t||t.setState("ad-playing",!0),this._state.toggleState(oe.PLAYING,!0)};this.on("ad-play-requested",e),this.on("ad-started",e),this.on("ad-resumed",e);const t=e=>{var t,s;null===(t=this.videoTag)||void 0===t||t.setState("ad-paused","ad-paused"===(null==e?void 0:e.type)),null===(s=this.videoTag)||void 0===s||s.setState("ad-playing",!1),this.adPlaying&&this._state.toggleState(oe.PLAYING,!1)};this.on("ad-break-completed",t),this.on("ad-teardown",t),this.on("ad-playback-error",t),this.on("ad-request-error",t),this.on("ad-paused",t),this.on("ad-skipped",t),this.on("ad-completed",t),this.on("ad-break-completed",()=>{requestAnimationFrame(()=>{this._state.toggleState(oe.BREAK_ACTIVE,!1)})}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),t(),this._state.toggleState(oe.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async e=>{if(Ie("Ads.on(RELOAD_AD_REQUESTED)",e),this._schedule){if(t(),e)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(oe.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(oe.AD_AVAILABLE,!1))}})}async initialize(e,t={},s){return Ie("Ads.initialize():",e,t,s),this._state.toggleState(oe.INITIALIZING,!0),Object.assign(this.opts,t),Array.isArray(e)&&this.setSchedule(e),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},t.parameters||{},{autoplay:t.autoplay,muted:t.muted})),this.adapter.isReady()&&await this.adapterInitialized(s),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(e){Ie("Ads.setVideoTag():",e),await this.adapter.setVideoTag(e),this.trigger("ad-videotag-attached",e),this.adapter.isReady()&&await this.adapterInitialized(),e.on("request/ad/pause",()=>this.adapter.pause()),e.on("request/ad/play",()=>this.adapter.resume()),e.on("request/ad/muteunmute",()=>e.toggleMute()),e.on("volumechange",()=>{this.adapter.volume(e.muted?0:0==e.volume?.1:e.volume)}),e.on("src",()=>e.hasState("ad-playing")||e.hasState("ad-paused")?(this.stop(),this.adapter.isLinearAd()?(this.setIsContentProcessingNewSrc(!0),void this.once("ad-break-completed",()=>{setTimeout(()=>{this.setIsContentProcessingNewSrc(!1),this.onContentNewSrc()},0)})):this.onContentNewSrc()):this.onContentNewSrc())}waitForVideoTag(){return new Promise(e=>{const t=this.adapter.getVideoTag();if(t)return e(t);this.on("ad-videotag-attached",t=>{this.once(g,()=>e(t))})})}async adapterInitialized(e){Ie("Ads.adapterInitialized()"),this._state.toggleState(oe.INITIALIZING,!1),this._state.toggleState(oe.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,e),this.checkIfBreakComplete(),this.adapter.isAdPod()||e&&!this.opts.autoplay||this.trigger("ad-teardown")}async fetchNextAd(e,t=0){var s,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(t>50)throw this._state.toggleState(oe.FATAL_ERROR,!0),this._state.toggleState(oe.FETCHING_AD,!1),new Error("Ads.fetchNextAd() :max_recursion_depth");const r=(null===(s=this._schedule)||void 0===s?void 0:s.getNextAd())||(null===(i=this._schedule)||void 0===i?void 0:i.getPostroll());if(!r||this.adapter.canDismissNonLinear()||-1===e)if(this._schedule.waitForLoad(e,r,this.opts.preload_ads))this._state.toggleState(oe.FETCHING_AD,!1);else if(r===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),r){Ie("Ads.fetchNextAd",r),this._state.toggleState(oe.FETCHING_AD,!0);try{return await this.requestAd(r),this._state.toggleState(oe.AD_AVAILABLE,!0),void this._state.toggleState(oe.FETCHING_AD,!1)}catch(s){return Ie("Ads.fetchNextAd(err: %o, ad: %o)",s,r),this.setLastAd(r),r!==this._schedule.getPostroll()?await this.fetchNextAd(e,++t):void this._state.toggleState(oe.FETCHING_AD,!1)}}else this._state.toggleState(oe.FETCHING_AD,!1)}skipAdsOnSeek(e){if(!this._schedule)return;let t=this._schedule.getNextAd();for(;t&&t.time<e;)this._schedule.increment(),t=this._schedule.getNextAd()}async setCurrentTime(e,t=!1,s=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(oe.FETCHING_AD))return;if(this._state.hasAny(oe.PLAYING)&&this.adapter.isLinearAd())return;const i=0===e&&0===this._schedule.getNextIndex();try{if(s&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(e),this._state.hasAny(oe.AD_AVAILABLE)||await this.fetchNextAd(e),!this._state.hasAny(oe.AD_AVAILABLE)||!this.shallPlayAd(e)||t)return;await this.playAd(),await this.setCurrentTime(e),this.checkIfBreakComplete()}catch(e){Ie("setCurrentTime: Error(from: setCurrentTime, message: %s)",e.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var e;if(!this._state.hasAny(oe.AD_AVAILABLE))return;this._state.toggleState(oe.AD_AVAILABLE,!1),this._state.toggleState(oe.BREAK_ACTIVE,!0);const t=null===(e=this._schedule)||void 0===e?void 0:e.getCurrentAd();try{await this.adapter.playAd()}catch(e){console.error("Ads.playAd: error",e)}finally{t&&this.setLastAd(t)}}checkIfBreakComplete(){if(!this._state.hasAny(oe.BREAK_ACTIVE))return Ie("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());Ie("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(oe.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger("ad-break-completed")}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(e,t){if(t&&!isNaN(t)&&this._schedule&&this._schedule.updateContentDuration(t),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(e);this._schedule=new Schedule(e,{preload_advance:this.opts.preload_advance,content_duration:t?0:t})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(e,t={}){var s;if(!this.adapter.getVideoTag())return;if(!this._state)return;if("ad-break-completed"===e&&this._state.hasAny(oe.BREAK_ACTIVE)&&!this.adapter.isAdPod())return Ie("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=t)||"object"!=typeof i||ae(i)!==re)return this.dispatch(e,t);var i;const r=Object.assign({},this.adapter.getOpts()||{},(null===(s=this._schedule)||void 0===s?void 0:s.getCurrentAd())||{},{ad_type:this.ad_type},t);return this.dispatch(e,r)}dispatch(e,t){const s=this.adapter.getVideoTag();if(s){Ie(":dispatch",e,t),this.adapter.isAdPod()&&"object"==typeof t&&"time"in t&&"preroll"!==t.ad_type&&(t.time=this.adapter.getAdBreakTime());try{const i={event:"ads/"+e,detail:{outstream:t.outstream,ad_type:t.ad_type,ad_break_time:t.time,ad_remaining_seconds:t.remaining,ad_muted:t.muted,ad_duration_seconds:t.duration,ad_error_reason:t.reason,ad_vast_error:t.vast_error,ad_vast_error_type:t.vast_error_type,ad_request_load_type:t.request_load_time}};s.dispatchEvent(new CustomEvent("health:record",{detail:i}))}catch(e){Ie(":error",e)}f(s,e,t),this.emit(e,t)}}get ad_type(){if(!this.videoTag)return;if(!this.adapter.isAdPod())return this._schedule&&this._schedule.getCurrentType();const e=this.adapter.getAdBreakTime();return-1===e?"postroll":this.videoTag.hasState("is-live")||e<1?"preroll":"midroll"}shouldRestartContent(){if(this.getIsContentProcessingNewSrc())return!1;if(this.adapter.isAdPod())return!0;const e=this.getLastAd();return!e||!e.outstream&&!1!==e.restart}async finished(e){if(this._schedule&&(Ie("Ads.finished"),!(this.adapter.isCustomPlaybackEnabled()&&this._state.hasAny(oe.PLAYING)&&this.adapter.isLinearAd()))){Ie("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return Ie("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(oe.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(e){Ie("Ads.finished: postroll failed:",e)}finally{this.trigger("ad-postroll-finished"),this.checkIfBreakComplete(),"function"==typeof e&&e()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(e){var t;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(oe.FATAL_ERROR))&&!!(null===(t=this._schedule)||void 0===t?void 0:t.shallPlayAd(e)))}setLastAd(e){return this._lastAd=e,this}setIsContentProcessingNewSrc(e){this.content_processing_src=e}getLastAd(){return this._lastAd}getIsContentProcessingNewSrc(){return this.content_processing_src}mergeMacros(e={}){return this._macros=this._macros.fork(Object.assign({},e)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(e){this.adapter&&this.adapter.onResize(e)}async requestAd(e,t=0,s=this.opts.timeout){if(!this._state)return;Ie("Ads.requestAd(ad: %o)",{ad:e,timeout:s,idx:t});const i=await async function e(t){if("function"==typeof t)return[await ie(t)];if("string"==typeof t)return[await ie(t)];if(Array.isArray(t)){const e=t;return await Promise.all(e.map(ie))}if("object"==typeof t&&t&&t.adTag)return await e(t.adTag);throw new Error(`\n unhandled ads type ${typeof t}:\n ${JSON.stringify(t)}\n can be:\n | Array<string>\n | string\n | function\n | {adTag: Array<string>|string|function}\n `)}(e);if(void 0===i[t])return setTimeout(()=>this.trigger("ad-teardown"),0),Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[t])return await this.requestAd(i,t+1,s);this.trigger("ad-requested",e);const r=this._macros.compile(i[t],te(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(r,s)}catch(e){return Ie(`Ads.requestAd(:fallback, idx: ${t}, length: ${i.length}, adTag: ${i[t]})\nError `,{adTag:i,err:e}),this.requestAd(i,t+1,s)}}resetSchedule(e){this._schedule&&this._schedule.reset(e)}get adPlaying(){return this._state&&this._state.hasAny(oe.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(oe.BREAK_ACTIVE)}get adRequesting(){return this._state.hasAny(oe.FETCHING_AD)}get adLinear(){return this.adBreak&&this.adapter.isLinearAd()}}var Ce=new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"}),Ue=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});function xe(e){return Object.assign({muted:!1,timeout:250,inline:!1},e)}function Fe(e,t){var s=e.muted,i=e.timeout,r=e.inline,a=t(),n=a.element,o=a.source,d=void 0,l=void 0,c=void 0;return n.muted=s,!0===s&&n.setAttribute("muted","muted"),!0===r&&n.setAttribute("playsinline","playsinline"),n.src=o,new Promise((function(e){d=n.play(),l=setTimeout((function(){c(!1,new Error("Timeout "+i+" ms has been reached"))}),i),c=function(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.remove(),n.srcObject=null,clearTimeout(l),e({result:t,error:s})},void 0!==d?d.then((function(){return c(!0)})).catch((function(e){return c(!1,e)})):c(!0)}))}var Be={audio:function(e){return Fe(e=xe(e),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Ce)}}))},video:function(e){return Fe(e=xe(e),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(Ue)}}))}};let qe=void 0;async function je(e=!0){return qe||(qe=await Be.video({timeout:500,muted:e}),qe)}const He=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});var ze=Object.freeze({__proto__:null,STICKY_CONTROLS:1,NO_FULLSCREEN:2,NO_AD_INDICATOR:4,AD_ATTRIBUTION:8,AD_CHOICES:16,REMAINING_TIME:32,VOLUME_BAR:64});const Ve=["progress","duration","remaining"];class AdUI extends HTMLElement{static get observedAttributes(){return Ve}constructor(e){super(),this.player=e,this.className="fp-ad-ui",this.append(...e.createComponents("flowplayer-ad-controls","flowplayer-ad-countdown")),e.on("ad/set-ui-flags",e=>{let{ui_flags:t}=e.detail;if(t=t||0,(8&t)>0){const e=document.createElement("div");e.classList.add("ad-attribution"),e.textContent=this.player.i18n("ads.advertisement","Advertisement"),this.append(e)}})}}const Ge=S("fpads:native:outstream"),We={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Qe,$e;!function(e){e.OUTSTREAM_VISIBLE="ads-outstream-visible",e.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",e.OUTSTREAM_TEARDOWN="ads-outstream-teardown",e.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Qe||(Qe={})),function(e){e[e.None=0]="None",e[e.Booting=1]="Booting",e[e.Ready=2]="Ready",e[e.Disposed=3]="Disposed"}($e||($e={}));class Outstream{constructor({ads:e,root:t,content:s,ima:i}){this.state=$e.None,Ge("creating Outstream instance"),this.content=s,this.ads=e,this.root=t,this.ima=i,this.aspectRatio=s.videoHeight/s.videoWidth,this.dimensions=function(e){if(e.clientWidth>0||e.clientHeight)return h(e);const t={height:e.style.height};p(e,"opacity",0),p(e,"display","absolute"),p(e,"display","inline-block"),p(e,"height","auto");const s=h(e);return p(e,"height",t.height),p(e,"opacity",1),s}(this.root),this.adUi=new AdUI(s),this.initialVolumeState={},t.classList.add(We.OUTSTREAM),t.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",e=>{var t;if(this.state==$e.Disposed)return;const s=!!(null===(t=e.detail)||void 0===t?void 0:t.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:s}))}),s.on("resize",e=>{if(this.state==$e.Disposed)return;const t=e.detail;t&&(this.dimensions={width:t.contentRect.width,height:t.contentRect.height},this.ads.resize(this.dimensions))});let r=1,a=!0;s.on("intersectionchange",e=>{if(this.state==$e.Disposed)return;const t=e.detail;if(t)switch(this.state){case $e.Booting:return Ge(":boot skipping intersectionchange");case $e.None:return this.state=$e.Booting,this.begin_life_cycle();case $e.Ready:if(r=t.ratio,t.ratio>=.5&&this.ads.adPlaying)return;t.ratio>=.5&&a&&this.ads.resume(),t.ratio<.5&&this.ads.pause()}}),this.content.on("ad-paused",()=>a=r<.5),this.setup(),setTimeout(()=>(this.state=$e.Booting,this.begin_life_cycle()),0)}hide(){return this}restore_aspect_ratio(){return Ge(`Outstream.restore_aspect_ratio(${this.aspectRatio})`),this.content.setOpts({ratio:this.aspectRatio}),this}show(){this.root.classList.remove(Outstream.CLASS.HIDDEN),this.root.classList.add(Outstream.CLASS.SHOWING),this.content.setState("ad-linear",!0)}async begin_life_cycle(){var e;this.state=$e.Ready;const{error:t,result:s}=await je(!1),{result:i}=await je(!0);this.content.emit("ad/set-ui-flags",{ui_flags:null===(e=this.content.opts.ads)||void 0===e?void 0:e.ui}),this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!s&&!i),muted:!s},Ge("Outstream.show() :autoplay >> sound="+s),t&&this.content&&!s&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await P({ads:this.ads,content:this.content,adContainer:this.adUi,ima:this.ima,state:{listening:!1},config:this.content.opts}),U({content:this.content,ads:this.ads}),this.state=$e.Ready}attach_ad_listeners(){this.ads.once("ad-pause-content",()=>{this.show(),this.ads.adPlaying&&this.ads.pause()});const e=()=>{M.forEach(t=>this.ads.removeListener(t,e));const t=new CustomEvent(Qe.OUTSTREAM_TEARDOWN);Ge("Outstream(:teardown)",t),this.content.dispatchEvent(t)};M.forEach(t=>this.ads.once(t,e)),this.content.once(Qe.OUTSTREAM_TEARDOWN,e=>{setTimeout(()=>{if(e.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),N({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adUi,ima:this.ima,content:this.content,root:this.content.root,state:{started:!0,listening:!1},initial:{muted:!0,volume:1}})}empty_src(){this.content.setSrc({type:"video/mp4",src:URL.createObjectURL(He)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.content.setState("ad-linear",!1),this.empty_src()}reset_ui(){const e=this.root;e.classList.remove(Outstream.CLASS.SHOWING),e.classList.remove(Outstream.CLASS.OUTSTREAM)}dispose(){if(this.state==$e.Disposed)return;const e=this.root,t=this.content;this.reset_ui(),e.classList.add(Outstream.CLASS.OUTSTREAM),e.classList.add(Outstream.CLASS.DONE);this.video=this.container=this.ads=0,this.state=$e.Disposed,t.destroy(),e.innerHTML=""}}function Ke(e){return e&&"number"==typeof e.time}function Ye(e){return e&&"number"==typeof e.percentage&&"number"!=typeof e.time}Outstream.CLASS=We;const Ze=S("ads/ima/sdk");var Je,Xe;async function et(e,t){var s;const i=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(t?null==i?void 0:i.dai:i)return void Ze(":noop");const r=t?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":e._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(e){return new Promise((t,s)=>{let i=document.querySelector(`script[src='${e}']`);if(i)return tt(i,t,s);i=document.createElement("script"),i.setAttribute("state",Je.LOADING),tt(i,t,s),i.src=e,document.head.appendChild(i)})}(r),void Ze(":loaded")}catch(e){Ze(":error "+e.message,e)}}function tt(e,t,s){const i=e.getAttribute("state");if(i&&[Je.ERROR,Je.LOADED].includes(i))return t(void 0);e.addEventListener("load",()=>{e.setAttribute("state",Je.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(t=>{e.addEventListener(t,()=>{e.setAttribute("state",Je.ERROR),s("script failed to load")},{once:!0})})}!function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(Je||(Je={})),function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(Xe||(Xe={}));const st=S("ads/ima/sdk"),it="https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js";async function rt(e){var t;const s=e._storage.getItem("prebid/debug")?it:"https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js";if(null===(t=null===window||void 0===window?void 0:window.pbjs)||void 0===t?void 0:t.version)st(":noop");else if(!document.querySelector(`script[src='${s}']`))try{return await async function(e){return new Promise((t,s)=>{let i=document.querySelector(`script[src='${e}']`);i||(i=document.createElement("script")),i.setAttribute("state",Xe.LOADING);const r=i.getAttribute("state");if(r&&[Xe.ERROR,Xe.LOADED].includes(r))return t(void 0);i.addEventListener("load",()=>{i.setAttribute("state",Xe.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(e=>{i.addEventListener(e,()=>{i.setAttribute("state",Xe.ERROR),s("script failed to load")},{once:!0})}),i.src=e,document.head.appendChild(i)})}(s),void st(":loaded")}catch(e){console.warn(":error / failed to load prebid.js / "+e.message,e)}}const at=window.pbjs=window.pbjs||{};at.que=at.que||[];class PrebidAdController{constructor(e,t){this.player=e,this.config=t,this.player=e,this.bestOffer="",at.que.push(()=>{var s,i;const r=this.createAdUnit();at.addAdUnits(r);const a=(null===(i=null===(s=t.ads)||void 0===s?void 0:s.prebid)||void 0===i?void 0:i.pbjs)||{};at.setConfig(Object.assign({enableSendAllBids:!0},a)),e.emit("ad/pbjs",{pbjs:at}),at.requestBids({bidsBackHandler:e=>{var s,i,a,n,o;const d=null===(s=e[this.prebidCode()])||void 0===s?void 0:s.bids;if(!d)return;if(0==d.length)return;const l=d[0];if(l&&l.vastUrl)return this.bestOffer=l.vastUrl;const c=at.adServers.dfp.buildVideoUrl({adUnit:r,params:{iu:null===(a=null===(i=t.ads)||void 0===i?void 0:i.prebid)||void 0===a?void 0:a.iu,cust_params:null===(o=null===(n=t.ads)||void 0===n?void 0:n.prebid)||void 0===o?void 0:o.custom_params,output:"vast"}});this.bestOffer=c}})})}prebidCode(){var e,t;return(null===(t=null===(e=this.config.ads)||void 0===e?void 0:e.prebid)||void 0===t?void 0:t.code)||this.player.root.id}videoInfo(){var e,t;return(null===(t=null===(e=this.config.ads)||void 0===e?void 0:e.prebid)||void 0===t?void 0:t.video)||{context:"instream",playerSize:[[this.player.videoWidth||640,this.player.videoHeight||480]]}}createAdUnit(){var e,t;return{code:this.prebidCode(),mediaTypes:{video:this.videoInfo()},bids:null===(t=null===(e=this.config.ads)||void 0===e?void 0:e.prebid)||void 0===t?void 0:t.bidders}}vastGenerator(){return async()=>this.bestOffer}}function nt(e,t){var s,i;const r=null===(s=t.ads)||void 0===s?void 0:s.prebid;if(!r)return;if((null===(i=e.prebidController)||void 0===i?void 0:i.config)===t)return;e.prebidController||(e.prebidController=new PrebidAdController(e,t),rt(e));const a=e.prebidController;if(a){const t=r.breaks.map(e=>({adTag:a.vastGenerator(),time:e}));e.setOpts({ima:{ads:t}})}}const ot=S("ads/index");async function dt(e,t,s){var i;let r;if(s.on("config",()=>{var t,i,a;void 0===r&&e.autoplay&&!s.currentSrc&&(a=e.autoplay,r=!0===a?v.ON:!1===a?v.OFF:a,e.autoplay=0),(null===(t=e.ads)||void 0===t?void 0:t.prebid)&&nt(s,e),Array.isArray(null===(i=null==e?void 0:e.ima)||void 0===i?void 0:i.ads)&&z(s)&&Object.assign(e,{hls:{native:!0}}),s.ads&&d()}),s.once("loadstart",()=>{setTimeout(()=>{var t;if(!Array.isArray(null===(t=null==e?void 0:e.ima)||void 0===t?void 0:t.ads)&&void 0!==r){if(e.autoplay=r,s.setState("is-autoplay",!0),!s.hasState(_))return s.once("viewenter",()=>s.togglePlay(!0));s.togglePlay(!0)}},0)}),await et(s),!("google"in window))return console.warn("google.ima unavailable");let a=!1;const n=s.ads=new AdsController,o=n.analytics;function d(){const i=e.ima;if(!i||!Array.isArray(i.ads))return;const d=e.duration||s.duration;if(i.ads=function(e,t){return Array.isArray(e)?e.filter(e=>Ke(e)||Ye(e)).reduce((e,s)=>{if(Ke(s))return e.push(s),e;if(s.lazy)return e.push(s),e;if(Ye(s)){const i=Object.assign({},s),r=s.percentage?s.percentage*t:0;return isNaN(r)||(i.time=r<0||r===t?-1:r),e.push(i),e}return e},[]):(console.warn("AdSchedule was not an Array"),[])}(i.ads,d),n.setSchedule(i.ads,d),e.metadata&&Analytics.mergeMetadata(o,e.metadata),e.metadata&&n.mergeMacros(e.metadata),e.metadata&&i.parameters&&(i.parameters=Object.assign(Object.assign({},i.parameters),e.metadata)),Analytics.mergeMetadata(o,{muted:e.muted||!1,autoplay:e.autoplay||!1}),!a){if(a=!0,e.lang&&!i.Locale&&(i.Locale=e.lang),Schedule.isOutstream(i.ads))return ot("is outstream, returning"),new Outstream({root:t,content:s,ads:n,ima:i});k({config:Object.assign(Object.assign({},e),{autoplay:r}),root:t,content:s,ads:n,ima:i})}}n.resize(h(t)),n.on("ad-postroll-finished",()=>{n.adapter.isCustomPlaybackEnabled()&&n.once("ad-break-completed",()=>{s.src=s.original_src,s.once("canplay",()=>{s.togglePlay(!1)}),s.webkitExitFullscreen()})}),s.on("reap",(function(){n&&n.destroy()})),(null===(i=e.ads)||void 0===i?void 0:i.prebid)&&nt(s,e),d()}class AdControls extends HTMLElement{constructor(e){super(),this.player=e,this.classList.add("fp-ad-controls"),this.append(this.adRemainingTime(),T(this.player,"flowplayer-ad-indicator"),this.playbackButtons(),this.volumeBtn(),T(this.player,"flowplayer-volume-bar"),...this.fullscreenIcons(),this.adChoices()),e.on("ad/set-ui-flags",this.applyStyleFlags.bind(this))}fullscreenIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(e=>(e.onclick=()=>this.player.toggleFullScreen(),e))}volumeBtn(){const e=T(this.player,"flowplayer-volume-icon");return e.onclick=()=>this.player.emit("request/ad/muteunmute"),e}playbackButtons(){const e=document.createElement("div");e.classList.add("ad-playback-controls");const t=T(this.player,"flowplayer-small-play-icon"),s=T(this.player,"flowplayer-small-pause-icon");return t.addEventListener("click",()=>{this.player.emit("request/ad/play"),setTimeout((function(){s.focus&&s.focus()}),100)}),s.addEventListener("click",()=>{this.player.emit("request/ad/pause"),setTimeout((function(){t.focus&&t.focus()}),100)}),e.append(t,s),e}adChoices(){const e=document.createElement("div");return e.classList.add("fp-ad-choices"),e.textContent=this.player.i18n("ads.adchoices","AdChoices"),e.addEventListener("click",e=>{e.preventDefault(),this.player.togglePlay(!1),window.open("https://adssettings.google.com","_blank")}),e}adRemainingTime(){const e=document.createElement("div");return e.classList.add("fp-ad-remaining","fp-color-text"),this.prepend(e),this.player.on("ad-progress",t=>{const s=t.detail.remaining;e.textContent=function(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const s=Math.floor(e/3600);let i=Math.floor(e/60);return e-=60*i,s>=1?(i-=60*s,t+s+":"+y(i)+":"+y(e)):t+y(i)+":"+y(e)}(parseFloat(s+""))}),e}applyStyleFlags(e){var t;const s=null!==(t=e.detail.ui_flags)&&void 0!==t?t:0;this.classList.toggle("is-ad-controls-sticky",(1&s)>0),this.classList.toggle("no-indicator",(4&s)>0),this.classList.toggle("is-ad-choices",(16&s)>0),this.classList.toggle("no-volume-bar",0==(64&s)),this.classList.toggle("is-ad-remaining",(32&s)>0),this.classList.toggle("no-fullscreen",(2&s)>0)}}class AdCountdown extends HTMLElement{static get observedAttributes(){return["remaining"]}constructor(e){super(),this.player=e,this.className="fp-ad-countdown",e.on("ad-progress",e=>{const{duration:t,remaining:s}=e.detail;this.setAttribute("duration",t+""),this.setAttribute("remaining",s+"")}),e.on("ad-started",e=>{e.detail.linear&&(this.style.setProperty("--ad-percent-previous","0"),this.style.setProperty("--ad-percent-complete","0"))}),this.addEventListener("animationend",()=>{const e=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",e)})}attributeChangedCallback(e,t,s){switch(e){case"remaining":return this.onRemaining(s)}}onRemaining(e){const t=parseFloat(this.getAttribute("duration")||"0");e||(e=t+"");const s=parseFloat(e),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const r=((t-s)/t*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",r),this.classList.add("go")})}}class AdIndicator extends HTMLElement{static get observedAttributes(){return["position","totals"]}constructor(e){super(),this.player=e,this.render(),e.on("ad-started",e=>{const{position:t,totals:s}=e.detail.ad;this.setAttribute("position",t+""),this.setAttribute("totals",s+"")})}attributeChangedCallback(e,t){switch(e){case"position":case"totals":return this.updateText()}}updateText(){if(!this.element)return;const e=parseFloat(this.getAttribute("position")||"0"),t=parseFloat(this.getAttribute("totals")||"0");this.element.textContent=`${this.player.i18n("ads.indicator","ADS")} ${e} / ${t}`}render(){this.element=document.createElement("div"),this.element.classList.add("ad-indicator","fp-color-text"),this.element.textContent=this.player.i18n("ads.indicator","ADS"),this.append(this.element)}}var lt,ct=Object.freeze({__proto__:null,SINGlE_INLINE_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_SKIPPABLE_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirectlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_ERROR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_BROKEN:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&nofb=1&correlator=",SINGLE_VPAID_20_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinearvpaid2js&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_VPAID_20_NON_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dnonlinearvpaid2js&ciu_szs=728x90%2C300x250&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_NON_LINEAR_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/nonlinear_ad_samples&sz=480x70&cust_params=sample_ct%3Dnonlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_SESSION_AD_RULE_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sar%3Da0f2&ciu_szs=300x250&ad_rule=1&gdfp_req=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonly&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator="});const{samsung_tv:ut}=u(),ht=((lt=class Ads{constructor(e){this.umd=e,L(e,O,AdUI),L(e,"flowplayer-ad-controls",AdControls),L(e,"flowplayer-ad-countdown",AdCountdown),L(e,"flowplayer-ad-indicator",AdIndicator)}init(e,t,s){if(c.from_token(e.token||"").is_granted(c.permissions.ADS)&&!ut)return dt(e,t,s)}}).pluginName="ads",lt.events=m,lt.ui=ze,lt.tags=ct,lt);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;return"function"==typeof s?(s(t),t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t),t)}(window,ht)}));
|
|
7
|
+
*/const ye=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return ce}static get ENGINE_MAP(){return pe}static get OS_MAP(){return he}static get PLATFORMS_MAP(){return ue}}.parse(window.navigator.userAgent),{platform:Ae,os:be,browser:we}=ye,Ee=e=>e&&e.toLowerCase();var Se={rnd:Math.random().toString(36).substr(2,32),os:Ee(be.name+(be.versionName?" "+be.versionName:"")),device:Ee(Ae.type),browser:Ee(we.name),browser_version:(we&&we.version?we.version:"unknown").split(".").shift(),plugin_version:"3.26.0-rc"};const Te="https://fp-eu-w1-aai.flowplayer.com/in",Le="POST",Oe=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],Re=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Me=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],ke=S("ads/analytics"),Pe=RequestQueue.of(),De=(...e)=>Object.assign({},...e);class Analytics{static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,De(e.metadata,t,{player_version:"3.26.0-rc"})),e}constructor(e,t={}){this.emitter=e,this.metadata=De(Se,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),ke(this),this.wireup()}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,i=De(this.metadata,{event_type:e},s),r=Analytics.pluck_valid_keys(this,i),a=Analytics.ensure_required_keys(this,r);if(ke(`Event[${e}]`,{payload:r,observation:s}),a.length)return ke(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${a}`,r);RequestQueue.rpush(Pe,[Te,Le,r])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const Ie=S("ads/controller"),Ne={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends class EventBus{constructor(e=document.createElement("div"),t=[]){this._bus=e,this._listeners=t}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(e,t){const s=new CustomEvent(e,{detail:t||{}});this._bus.dispatchEvent(s)}on(e,t){this._listeners.push([e,t]),this._bus.addEventListener(e,t,{passive:!0})}once(e,t){this._bus.addEventListener(e,t,{once:!0})}removeListener(e,t){this._bus.removeEventListener(e,t)}}{constructor(e={}){var t;super(),this.adapter=function(e,t){return e.adapter?new e.adapter(t):new IMA(t)}(e,this),this.opts=Object.assign(Object.assign({},Ne),e),this.analytics=(t=this,Analytics.of(t,{required_keys:Re,optional_keys:Me,events:Oe})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(e.parameters||{}),this.wireup(),this.content_processing_src=!1}reset(){return this.removeAllListeners(),this.wireup(),this.analytics&&this.analytics.wireup(),this._state.reset(),this.adapter.reset(),this}destroy(){this.removeAllListeners(),this.analytics&&this.analytics.destroy(),this.adapter&&this.adapter.destroy();this.analytics=void 0,this.opts=void 0,this.adapter=void 0,this._state=void 0,this._schedule=void 0,this._lastAd=void 0,this._macros=void 0}stop(){this.adapter&&this.adapter.stop()}onContentNewSrc(){this._state.reset(),this.adapter.destroyManager(),this.adapter.contentComplete()}wireup(){const e=()=>{var e,t;null===(e=this.videoTag)||void 0===e||e.setState("ad-paused",!1),null===(t=this.videoTag)||void 0===t||t.setState("ad-playing",!0),this._state.toggleState(oe.PLAYING,!0)};this.on("ad-play-requested",e),this.on("ad-started",e),this.on("ad-resumed",e);const t=e=>{var t,s;null===(t=this.videoTag)||void 0===t||t.setState("ad-paused","ad-paused"===(null==e?void 0:e.type)),null===(s=this.videoTag)||void 0===s||s.setState("ad-playing",!1),this.adPlaying&&this._state.toggleState(oe.PLAYING,!1)};this.on("ad-break-completed",t),this.on("ad-teardown",t),this.on("ad-playback-error",t),this.on("ad-request-error",t),this.on("ad-paused",t),this.on("ad-skipped",t),this.on("ad-completed",t),this.on("ad-break-completed",()=>{requestAnimationFrame(()=>{this._state.toggleState(oe.BREAK_ACTIVE,!1)})}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),t(),this._state.toggleState(oe.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async e=>{if(Ie("Ads.on(RELOAD_AD_REQUESTED)",e),this._schedule){if(t(),e)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(oe.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(oe.AD_AVAILABLE,!1))}})}async initialize(e,t={},s){return Ie("Ads.initialize():",e,t,s),this._state.toggleState(oe.INITIALIZING,!0),Object.assign(this.opts,t),Array.isArray(e)&&this.setSchedule(e),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},t.parameters||{},{autoplay:t.autoplay,muted:t.muted})),this.adapter.isReady()&&await this.adapterInitialized(s),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(e){Ie("Ads.setVideoTag():",e),await this.adapter.setVideoTag(e),this.trigger("ad-videotag-attached",e),this.adapter.isReady()&&await this.adapterInitialized(),e.on("request/ad/pause",()=>this.adapter.pause()),e.on("request/ad/play",()=>this.adapter.resume()),e.on("request/ad/muteunmute",()=>e.toggleMute()),e.on("volumechange",()=>{this.adapter.volume(e.muted?0:0==e.volume?.1:e.volume)}),e.on("src",()=>e.hasState("ad-playing")||e.hasState("ad-paused")?(this.stop(),this.adapter.isLinearAd()?(this.setIsContentProcessingNewSrc(!0),void this.once("ad-break-completed",()=>{setTimeout(()=>{this.setIsContentProcessingNewSrc(!1),this.onContentNewSrc()},0)})):this.onContentNewSrc()):this.onContentNewSrc())}waitForVideoTag(){return new Promise(e=>{const t=this.adapter.getVideoTag();if(t)return e(t);this.on("ad-videotag-attached",t=>{this.once(g,()=>e(t))})})}async adapterInitialized(e){Ie("Ads.adapterInitialized()"),this._state.toggleState(oe.INITIALIZING,!1),this._state.toggleState(oe.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,e),this.checkIfBreakComplete(),this.adapter.isAdPod()||e&&!this.opts.autoplay||this.trigger("ad-teardown")}async fetchNextAd(e,t=0){var s,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(t>50)throw this._state.toggleState(oe.FATAL_ERROR,!0),this._state.toggleState(oe.FETCHING_AD,!1),new Error("Ads.fetchNextAd() :max_recursion_depth");const r=(null===(s=this._schedule)||void 0===s?void 0:s.getNextAd())||(null===(i=this._schedule)||void 0===i?void 0:i.getPostroll());if(!r||this.adapter.canDismissNonLinear()||-1===e)if(this._schedule.waitForLoad(e,r,this.opts.preload_ads))this._state.toggleState(oe.FETCHING_AD,!1);else if(r===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),r){Ie("Ads.fetchNextAd",r),this._state.toggleState(oe.FETCHING_AD,!0);try{return await this.requestAd(r),this._state.toggleState(oe.AD_AVAILABLE,!0),void this._state.toggleState(oe.FETCHING_AD,!1)}catch(s){return Ie("Ads.fetchNextAd(err: %o, ad: %o)",s,r),this.setLastAd(r),r!==this._schedule.getPostroll()?await this.fetchNextAd(e,++t):void this._state.toggleState(oe.FETCHING_AD,!1)}}else this._state.toggleState(oe.FETCHING_AD,!1)}skipAdsOnSeek(e){if(!this._schedule)return;let t=this._schedule.getNextAd();for(;t&&t.time<e;)this._schedule.increment(),t=this._schedule.getNextAd()}async setCurrentTime(e,t=!1,s=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(oe.FETCHING_AD))return;if(this._state.hasAny(oe.PLAYING)&&this.adapter.isLinearAd())return;const i=0===e&&0===this._schedule.getNextIndex();try{if(s&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(e),this._state.hasAny(oe.AD_AVAILABLE)||await this.fetchNextAd(e),!this._state.hasAny(oe.AD_AVAILABLE)||!this.shallPlayAd(e)||t)return;await this.playAd(),await this.setCurrentTime(e),this.checkIfBreakComplete()}catch(e){Ie("setCurrentTime: Error(from: setCurrentTime, message: %s)",e.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var e;if(!this._state.hasAny(oe.AD_AVAILABLE))return;this._state.toggleState(oe.AD_AVAILABLE,!1),this._state.toggleState(oe.BREAK_ACTIVE,!0);const t=null===(e=this._schedule)||void 0===e?void 0:e.getCurrentAd();try{await this.adapter.playAd()}catch(e){console.error("Ads.playAd: error",e)}finally{t&&this.setLastAd(t)}}checkIfBreakComplete(){if(!this._state.hasAny(oe.BREAK_ACTIVE))return Ie("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());Ie("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(oe.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger("ad-break-completed")}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(e,t){if(t&&!isNaN(t)&&this._schedule&&this._schedule.updateContentDuration(t),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(e);this._schedule=new Schedule(e,{preload_advance:this.opts.preload_advance,content_duration:t?0:t})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(e,t={}){var s;if(!this.adapter.getVideoTag())return;if(!this._state)return;if("ad-break-completed"===e&&this._state.hasAny(oe.BREAK_ACTIVE)&&!this.adapter.isAdPod())return Ie("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=t)||"object"!=typeof i||ae(i)!==re)return this.dispatch(e,t);var i;const r=Object.assign({},this.adapter.getOpts()||{},(null===(s=this._schedule)||void 0===s?void 0:s.getCurrentAd())||{},{ad_type:this.ad_type},t);return this.dispatch(e,r)}dispatch(e,t){const s=this.adapter.getVideoTag();if(s){Ie(":dispatch",e,t),this.adapter.isAdPod()&&"object"==typeof t&&"time"in t&&"preroll"!==t.ad_type&&(t.time=this.adapter.getAdBreakTime());try{const i={event:"ads/"+e,detail:{outstream:t.outstream,ad_type:t.ad_type,ad_break_time:t.time,ad_remaining_seconds:t.remaining,ad_muted:t.muted,ad_duration_seconds:t.duration,ad_error_reason:t.reason,ad_vast_error:t.vast_error,ad_vast_error_type:t.vast_error_type,ad_request_load_type:t.request_load_time}};s.dispatchEvent(new CustomEvent("health:record",{detail:i}))}catch(e){Ie(":error",e)}f(s,e,t),this.emit(e,t)}}get ad_type(){if(!this.videoTag)return;if(!this.adapter.isAdPod())return this._schedule&&this._schedule.getCurrentType();const e=this.adapter.getAdBreakTime();return-1===e?"postroll":this.videoTag.hasState("is-live")||e<1?"preroll":"midroll"}shouldRestartContent(){if(this.getIsContentProcessingNewSrc())return!1;if(this.adapter.isAdPod())return!0;const e=this.getLastAd();return!e||!e.outstream&&!1!==e.restart}async finished(e){if(this._schedule&&(Ie("Ads.finished"),!(this.adapter.isCustomPlaybackEnabled()&&this._state.hasAny(oe.PLAYING)&&this.adapter.isLinearAd()))){Ie("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return Ie("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(oe.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(e){Ie("Ads.finished: postroll failed:",e)}finally{this.trigger("ad-postroll-finished"),this.checkIfBreakComplete(),"function"==typeof e&&e()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(e){var t;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(oe.FATAL_ERROR))&&!!(null===(t=this._schedule)||void 0===t?void 0:t.shallPlayAd(e)))}setLastAd(e){return this._lastAd=e,this}setIsContentProcessingNewSrc(e){this.content_processing_src=e}getLastAd(){return this._lastAd}getIsContentProcessingNewSrc(){return this.content_processing_src}mergeMacros(e={}){return this._macros=this._macros.fork(Object.assign({},e)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(e){this.adapter&&this.adapter.onResize(e)}async requestAd(e,t=0,s=this.opts.timeout){if(!this._state)return;Ie("Ads.requestAd(ad: %o)",{ad:e,timeout:s,idx:t});const i=await async function e(t){if("function"==typeof t)return[await ie(t)];if("string"==typeof t)return[await ie(t)];if(Array.isArray(t)){const e=t;return await Promise.all(e.map(ie))}if("object"==typeof t&&t&&t.adTag)return await e(t.adTag);throw new Error(`\n unhandled ads type ${typeof t}:\n ${JSON.stringify(t)}\n can be:\n | Array<string>\n | string\n | function\n | {adTag: Array<string>|string|function}\n `)}(e);if(void 0===i[t])return setTimeout(()=>this.trigger("ad-teardown"),0),Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[t])return await this.requestAd(i,t+1,s);this.trigger("ad-requested",e);const r=this._macros.compile(i[t],te(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(r,s)}catch(e){return Ie(`Ads.requestAd(:fallback, idx: ${t}, length: ${i.length}, adTag: ${i[t]})\nError `,{adTag:i,err:e}),this.requestAd(i,t+1,s)}}resetSchedule(e){this._schedule&&this._schedule.reset(e)}get adPlaying(){return this._state&&this._state.hasAny(oe.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(oe.BREAK_ACTIVE)}get adRequesting(){return this._state.hasAny(oe.FETCHING_AD)}get adLinear(){return this.adBreak&&this.adapter.isLinearAd()}}var Ce=new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"}),Ue=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});function xe(e){return Object.assign({muted:!1,timeout:250,inline:!1},e)}function Fe(e,t){var s=e.muted,i=e.timeout,r=e.inline,a=t(),n=a.element,o=a.source,d=void 0,l=void 0,c=void 0;return n.muted=s,!0===s&&n.setAttribute("muted","muted"),!0===r&&n.setAttribute("playsinline","playsinline"),n.src=o,new Promise((function(e){d=n.play(),l=setTimeout((function(){c(!1,new Error("Timeout "+i+" ms has been reached"))}),i),c=function(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.remove(),n.srcObject=null,clearTimeout(l),e({result:t,error:s})},void 0!==d?d.then((function(){return c(!0)})).catch((function(e){return c(!1,e)})):c(!0)}))}var Be={audio:function(e){return Fe(e=xe(e),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Ce)}}))},video:function(e){return Fe(e=xe(e),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(Ue)}}))}};let qe=void 0;async function je(e=!0){return qe||(qe=await Be.video({timeout:500,muted:e}),qe)}const He=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});var ze=Object.freeze({__proto__:null,STICKY_CONTROLS:1,NO_FULLSCREEN:2,NO_AD_INDICATOR:4,AD_ATTRIBUTION:8,AD_CHOICES:16,REMAINING_TIME:32,VOLUME_BAR:64});const Ve=["progress","duration","remaining"];class AdUI extends HTMLElement{static get observedAttributes(){return Ve}constructor(e){super(),this.player=e,this.className="fp-ad-ui",this.append(...e.createComponents("flowplayer-ad-controls","flowplayer-ad-countdown")),e.on("ad/set-ui-flags",e=>{let{ui_flags:t}=e.detail;if(t=t||0,(8&t)>0){const e=document.createElement("div");e.classList.add("ad-attribution"),e.textContent=this.player.i18n("ads.advertisement","Advertisement"),this.append(e)}})}}const Ge=S("fpads:native:outstream"),We={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Qe,$e;!function(e){e.OUTSTREAM_VISIBLE="ads-outstream-visible",e.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",e.OUTSTREAM_TEARDOWN="ads-outstream-teardown",e.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Qe||(Qe={})),function(e){e[e.None=0]="None",e[e.Booting=1]="Booting",e[e.Ready=2]="Ready",e[e.Disposed=3]="Disposed"}($e||($e={}));class Outstream{constructor({ads:e,root:t,content:s,ima:i}){this.state=$e.None,Ge("creating Outstream instance"),this.content=s,this.ads=e,this.root=t,this.ima=i,this.aspectRatio=s.videoHeight/s.videoWidth,this.dimensions=function(e){if(e.clientWidth>0||e.clientHeight)return h(e);const t={height:e.style.height};p(e,"opacity",0),p(e,"display","absolute"),p(e,"display","inline-block"),p(e,"height","auto");const s=h(e);return p(e,"height",t.height),p(e,"opacity",1),s}(this.root),this.adUi=new AdUI(s),this.initialVolumeState={},t.classList.add(We.OUTSTREAM),t.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",e=>{var t;if(this.state==$e.Disposed)return;const s=!!(null===(t=e.detail)||void 0===t?void 0:t.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:s}))}),s.on("resize",e=>{if(this.state==$e.Disposed)return;const t=e.detail;t&&(this.dimensions={width:t.contentRect.width,height:t.contentRect.height},this.ads.resize(this.dimensions))});let r=1,a=!0;s.on("intersectionchange",e=>{if(this.state==$e.Disposed)return;const t=e.detail;if(t)switch(this.state){case $e.Booting:return Ge(":boot skipping intersectionchange");case $e.None:return this.state=$e.Booting,this.begin_life_cycle();case $e.Ready:if(r=t.ratio,t.ratio>=.5&&this.ads.adPlaying)return;t.ratio>=.5&&a&&this.ads.resume(),t.ratio<.5&&this.ads.pause()}}),this.content.on("ad-paused",()=>a=r<.5),this.setup(),setTimeout(()=>(this.state=$e.Booting,this.begin_life_cycle()),0)}hide(){return this}restore_aspect_ratio(){return Ge(`Outstream.restore_aspect_ratio(${this.aspectRatio})`),this.content.setOpts({ratio:this.aspectRatio}),this}show(){this.root.classList.remove(Outstream.CLASS.HIDDEN),this.root.classList.add(Outstream.CLASS.SHOWING),this.content.setState("ad-linear",!0)}async begin_life_cycle(){var e;this.state=$e.Ready;const{error:t,result:s}=await je(!1),{result:i}=await je(!0);this.content.emit("ad/set-ui-flags",{ui_flags:null===(e=this.content.opts.ads)||void 0===e?void 0:e.ui}),this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!s&&!i),muted:!s},Ge("Outstream.show() :autoplay >> sound="+s),t&&this.content&&!s&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await P({ads:this.ads,content:this.content,adContainer:this.adUi,ima:this.ima,state:{listening:!1},config:this.content.opts}),U({content:this.content,ads:this.ads}),this.state=$e.Ready}attach_ad_listeners(){this.ads.once("ad-pause-content",()=>{this.show(),this.ads.adPlaying&&this.ads.pause()});const e=()=>{M.forEach(t=>this.ads.removeListener(t,e));const t=new CustomEvent(Qe.OUTSTREAM_TEARDOWN);Ge("Outstream(:teardown)",t),this.content.dispatchEvent(t)};M.forEach(t=>this.ads.once(t,e)),this.content.once(Qe.OUTSTREAM_TEARDOWN,e=>{setTimeout(()=>{if(e.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),N({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adUi,ima:this.ima,content:this.content,root:this.content.root,state:{started:!0,listening:!1},initial:{muted:!0,volume:1}})}empty_src(){this.content.setSrc({type:"video/mp4",src:URL.createObjectURL(He)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.content.setState("ad-linear",!1),this.empty_src()}reset_ui(){const e=this.root;e.classList.remove(Outstream.CLASS.SHOWING),e.classList.remove(Outstream.CLASS.OUTSTREAM)}dispose(){if(this.state==$e.Disposed)return;const e=this.root,t=this.content;this.reset_ui(),e.classList.add(Outstream.CLASS.OUTSTREAM),e.classList.add(Outstream.CLASS.DONE);this.video=this.container=this.ads=0,this.state=$e.Disposed,t.destroy(),e.innerHTML=""}}function Ke(e){return e&&"number"==typeof e.time}function Ye(e){return e&&"number"==typeof e.percentage&&"number"!=typeof e.time}Outstream.CLASS=We;const Ze=S("ads/ima/sdk");var Je,Xe;async function et(e,t){var s;const i=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(t?null==i?void 0:i.dai:i)return void Ze(":noop");const r=t?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":e._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(e){return new Promise((t,s)=>{let i=document.querySelector(`script[src='${e}']`);if(i)return tt(i,t,s);i=document.createElement("script"),i.setAttribute("state",Je.LOADING),tt(i,t,s),i.src=e,document.head.appendChild(i)})}(r),void Ze(":loaded")}catch(e){Ze(":error "+e.message,e)}}function tt(e,t,s){const i=e.getAttribute("state");if(i&&[Je.ERROR,Je.LOADED].includes(i))return t(void 0);e.addEventListener("load",()=>{e.setAttribute("state",Je.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(t=>{e.addEventListener(t,()=>{e.setAttribute("state",Je.ERROR),s("script failed to load")},{once:!0})})}!function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(Je||(Je={})),function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(Xe||(Xe={}));const st=S("ads/ima/sdk"),it="https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js";async function rt(e){var t;const s=e._storage.getItem("prebid/debug")?it:"https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js";if(null===(t=null===window||void 0===window?void 0:window.pbjs)||void 0===t?void 0:t.version)st(":noop");else if(!document.querySelector(`script[src='${s}']`))try{return await async function(e){return new Promise((t,s)=>{let i=document.querySelector(`script[src='${e}']`);i||(i=document.createElement("script")),i.setAttribute("state",Xe.LOADING);const r=i.getAttribute("state");if(r&&[Xe.ERROR,Xe.LOADED].includes(r))return t(void 0);i.addEventListener("load",()=>{i.setAttribute("state",Xe.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(e=>{i.addEventListener(e,()=>{i.setAttribute("state",Xe.ERROR),s("script failed to load")},{once:!0})}),i.src=e,document.head.appendChild(i)})}(s),void st(":loaded")}catch(e){console.warn(":error / failed to load prebid.js / "+e.message,e)}}const at=window.pbjs=window.pbjs||{};at.que=at.que||[];class PrebidAdController{constructor(e,t){this.player=e,this.config=t,this.player=e,this.bestOffer="",at.que.push(()=>{var s,i;const r=this.createAdUnit();at.addAdUnits(r);const a=(null===(i=null===(s=t.ads)||void 0===s?void 0:s.prebid)||void 0===i?void 0:i.pbjs)||{};at.setConfig(Object.assign({enableSendAllBids:!0},a)),e.emit("ad/pbjs",{pbjs:at}),at.requestBids({bidsBackHandler:e=>{var s,i,a,n,o;const d=null===(s=e[this.prebidCode()])||void 0===s?void 0:s.bids;if(!d)return;if(0==d.length)return;const l=d[0];if(l&&l.vastUrl)return this.bestOffer=l.vastUrl;const c=at.adServers.dfp.buildVideoUrl({adUnit:r,params:{iu:null===(a=null===(i=t.ads)||void 0===i?void 0:i.prebid)||void 0===a?void 0:a.iu,cust_params:null===(o=null===(n=t.ads)||void 0===n?void 0:n.prebid)||void 0===o?void 0:o.custom_params,output:"vast"}});this.bestOffer=c}})})}prebidCode(){var e,t;return(null===(t=null===(e=this.config.ads)||void 0===e?void 0:e.prebid)||void 0===t?void 0:t.code)||this.player.root.id}videoInfo(){var e,t;return(null===(t=null===(e=this.config.ads)||void 0===e?void 0:e.prebid)||void 0===t?void 0:t.video)||{context:"instream",playerSize:[[this.player.videoWidth||640,this.player.videoHeight||480]]}}createAdUnit(){var e,t;return{code:this.prebidCode(),mediaTypes:{video:this.videoInfo()},bids:null===(t=null===(e=this.config.ads)||void 0===e?void 0:e.prebid)||void 0===t?void 0:t.bidders}}vastGenerator(){return async()=>this.bestOffer}}function nt(e,t){var s,i;const r=null===(s=t.ads)||void 0===s?void 0:s.prebid;if(!r)return;if((null===(i=e.prebidController)||void 0===i?void 0:i.config)===t)return;e.prebidController||(e.prebidController=new PrebidAdController(e,t),rt(e));const a=e.prebidController;if(a){const t=r.breaks.map(e=>({adTag:a.vastGenerator(),time:e}));e.setOpts({ima:{ads:t}})}}const ot=S("ads/index");async function dt(e,t,s){var i;let r;if(s.on("config",()=>{var t,i,a;void 0===r&&e.autoplay&&!s.currentSrc&&(a=e.autoplay,r=!0===a?v.ON:!1===a?v.OFF:a,e.autoplay=0),(null===(t=e.ads)||void 0===t?void 0:t.prebid)&&nt(s,e),Array.isArray(null===(i=null==e?void 0:e.ima)||void 0===i?void 0:i.ads)&&z(s)&&Object.assign(e,{hls:{native:!0}}),s.ads&&d()}),s.once("loadstart",()=>{setTimeout(()=>{var t;if(!Array.isArray(null===(t=null==e?void 0:e.ima)||void 0===t?void 0:t.ads)&&void 0!==r){if(e.autoplay=r,s.setState("is-autoplay",!0),!s.hasState(_))return s.once("viewenter",()=>s.togglePlay(!0));s.togglePlay(!0)}},0)}),await et(s),!("google"in window))return console.warn("google.ima unavailable");let a=!1;const n=s.ads=new AdsController,o=n.analytics;function d(){const i=e.ima;if(!i||!Array.isArray(i.ads))return;const d=e.duration||s.duration;if(i.ads=function(e,t){return Array.isArray(e)?e.filter(e=>Ke(e)||Ye(e)).reduce((e,s)=>{if(Ke(s))return e.push(s),e;if(s.lazy)return e.push(s),e;if(Ye(s)){const i=Object.assign({},s),r=s.percentage?s.percentage*t:0;return isNaN(r)||(i.time=r<0||r===t?-1:r),e.push(i),e}return e},[]):(console.warn("AdSchedule was not an Array"),[])}(i.ads,d),n.setSchedule(i.ads,d),e.metadata&&Analytics.mergeMetadata(o,e.metadata),e.metadata&&n.mergeMacros(e.metadata),e.metadata&&i.parameters&&(i.parameters=Object.assign(Object.assign({},i.parameters),e.metadata)),Analytics.mergeMetadata(o,{muted:e.muted||!1,autoplay:e.autoplay||!1}),!a){if(a=!0,e.lang&&!i.Locale&&(i.Locale=e.lang),Schedule.isOutstream(i.ads))return ot("is outstream, returning"),new Outstream({root:t,content:s,ads:n,ima:i});k({config:Object.assign(Object.assign({},e),{autoplay:r}),root:t,content:s,ads:n,ima:i})}}n.resize(h(t)),n.on("ad-postroll-finished",()=>{n.adapter.isCustomPlaybackEnabled()&&n.once("ad-break-completed",()=>{s.src=s.original_src,s.once("canplay",()=>{s.togglePlay(!1)}),s.webkitExitFullscreen()})}),s.on("reap",(function(){n&&n.destroy()})),(null===(i=e.ads)||void 0===i?void 0:i.prebid)&&nt(s,e),d()}class AdControls extends HTMLElement{constructor(e){super(),this.player=e,this.classList.add("fp-ad-controls"),this.append(this.adRemainingTime(),T(this.player,"flowplayer-ad-indicator"),this.playbackButtons(),this.volumeBtn(),T(this.player,"flowplayer-volume-bar"),...this.fullscreenIcons(),this.adChoices()),e.on("ad/set-ui-flags",this.applyStyleFlags.bind(this))}fullscreenIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(e=>(e.onclick=()=>this.player.toggleFullScreen(),e))}volumeBtn(){const e=T(this.player,"flowplayer-volume-icon");return e.onclick=()=>this.player.emit("request/ad/muteunmute"),e}playbackButtons(){const e=document.createElement("div");e.classList.add("ad-playback-controls");const t=T(this.player,"flowplayer-small-play-icon"),s=T(this.player,"flowplayer-small-pause-icon");return t.addEventListener("click",()=>{this.player.emit("request/ad/play"),setTimeout((function(){s.focus&&s.focus()}),100)}),s.addEventListener("click",()=>{this.player.emit("request/ad/pause"),setTimeout((function(){t.focus&&t.focus()}),100)}),e.append(t,s),e}adChoices(){const e=document.createElement("div");return e.classList.add("fp-ad-choices"),e.textContent=this.player.i18n("ads.adchoices","AdChoices"),e.addEventListener("click",e=>{e.preventDefault(),this.player.togglePlay(!1),window.open("https://adssettings.google.com","_blank")}),e}adRemainingTime(){const e=document.createElement("div");return e.classList.add("fp-ad-remaining","fp-color-text"),this.prepend(e),this.player.on("ad-progress",t=>{const s=t.detail.remaining;e.textContent=function(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const s=Math.floor(e/3600);let i=Math.floor(e/60);return e-=60*i,s>=1?(i-=60*s,t+s+":"+y(i)+":"+y(e)):t+y(i)+":"+y(e)}(parseFloat(s+""))}),e}applyStyleFlags(e){var t;const s=null!==(t=e.detail.ui_flags)&&void 0!==t?t:0;this.classList.toggle("is-ad-controls-sticky",(1&s)>0),this.classList.toggle("no-indicator",(4&s)>0),this.classList.toggle("is-ad-choices",(16&s)>0),this.classList.toggle("no-volume-bar",0==(64&s)),this.classList.toggle("is-ad-remaining",(32&s)>0),this.classList.toggle("no-fullscreen",(2&s)>0)}}class AdCountdown extends HTMLElement{static get observedAttributes(){return["remaining"]}constructor(e){super(),this.player=e,this.className="fp-ad-countdown",e.on("ad-progress",e=>{const{duration:t,remaining:s}=e.detail;this.setAttribute("duration",t+""),this.setAttribute("remaining",s+"")}),e.on("ad-started",e=>{e.detail.linear&&(this.style.setProperty("--ad-percent-previous","0"),this.style.setProperty("--ad-percent-complete","0"))}),this.addEventListener("animationend",()=>{const e=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",e)})}attributeChangedCallback(e,t,s){switch(e){case"remaining":return this.onRemaining(s)}}onRemaining(e){const t=parseFloat(this.getAttribute("duration")||"0");e||(e=t+"");const s=parseFloat(e),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const r=((t-s)/t*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",r),this.classList.add("go")})}}class AdIndicator extends HTMLElement{static get observedAttributes(){return["position","totals"]}constructor(e){super(),this.player=e,this.render(),e.on("ad-started",e=>{const{position:t,totals:s}=e.detail.ad;this.setAttribute("position",t+""),this.setAttribute("totals",s+"")})}attributeChangedCallback(e,t){switch(e){case"position":case"totals":return this.updateText()}}updateText(){if(!this.element)return;const e=parseFloat(this.getAttribute("position")||"0"),t=parseFloat(this.getAttribute("totals")||"0");this.element.textContent=`${this.player.i18n("ads.indicator","ADS")} ${e} / ${t}`}render(){this.element=document.createElement("div"),this.element.classList.add("ad-indicator","fp-color-text"),this.element.textContent=this.player.i18n("ads.indicator","ADS"),this.append(this.element)}}var lt,ct=Object.freeze({__proto__:null,SINGlE_INLINE_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_SKIPPABLE_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirectlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_ERROR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_BROKEN:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&nofb=1&correlator=",SINGLE_VPAID_20_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinearvpaid2js&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_VPAID_20_NON_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dnonlinearvpaid2js&ciu_szs=728x90%2C300x250&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_NON_LINEAR_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/nonlinear_ad_samples&sz=480x70&cust_params=sample_ct%3Dnonlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_SESSION_AD_RULE_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sar%3Da0f2&ciu_szs=300x250&ad_rule=1&gdfp_req=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonly&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator="});const{samsung_tv:ut}=u(),ht=((lt=class Ads{constructor(e){this.umd=e,L(e,O,AdUI),L(e,"flowplayer-ad-controls",AdControls),L(e,"flowplayer-ad-countdown",AdCountdown),L(e,"flowplayer-ad-indicator",AdIndicator)}init(e,t,s){if(c.from_token(e.token||"").is_granted(c.permissions.ADS)&&!ut)return dt(e,t,s)}}).pluginName="ads",lt.events=m,lt.ui=ze,lt.tags=ct,lt);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;return"function"==typeof s?(s(t),t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t),t)}(window,ht)}));
|
package/plugins/analytics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.analytics=t())}(this,(function(){"use strict";const e=(...e)=>e.reduce((e,t)=>Object.assign(Object.assign({},e),t),{}),t=(e,t)=>{const r=e.lastIndexOf(t);return~r&&e.splice(r,1),e};class RequestQueue{static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return e;if(RequestQueue.is_high_water(e))return e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,r,n]){if(Date.now()<e.stats.ttl)return;const i=new XMLHttpRequest;e.open.push(i),i.timeout=RequestQueue.REQUEST_TIMEOUT_MS,i.ontimeout=function(){RequestQueue.handle_error(e,i)},i.onerror=function(t){RequestQueue.handle_error(e,i)},i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,i),Math.floor(i.status/100)},i.onload=function(){RequestQueue.rm(e,i),e.stats.failures&&e.stats.failures--},i.open(r,t),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{i.send(JSON.stringify(n))}catch(e){}}static rpush(e,...t){return t.forEach(t=>{e.pending.length>=RequestQueue.MAX_PENDING||(e.pending.push(t),RequestQueue.maybe_spawn_req(e))}),e}static lpop(e){return e.pending.shift()}static rm(e,r){return t(e.open,r),e}constructor(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.MAX_PENDING=5,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;var r=RequestQueue.of();const n=/:([a-zA-Z_]+)/g;class Log{static prepare(e,t){const r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r}static of(e){return new Log(e)}constructor(e){this.emitter=e}info(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.INFO,e))}error(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.ERROR,e))}warn(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.WARN,e))}}var i,o;Log.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},function(e){e.POST="POST",e.PUT="PUT",e.GET="GET"}(i||(i={}));class Tracker{static of(e,t){return new Tracker(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(t,r){return((t,...r)=>Object.keys(t).filter(e=>~r.indexOf(e)).reduce((r,n)=>e(r,{[n]:t[n]}),{}))(r,...t.valid_keys)}static merge_metadata(t,r={}){return t.metadata=Tracker.pluck_valid_keys(t,e(t.metadata,r)),t}static assert_emitter_api(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")}static create_listener(e,t,r){var n;e.listeners.push([t,r]),null===(n=e.emitter)||void 0===n||n.addEventListener(t,r)}constructor(t,i={}){const o=this;if(this.emitter=t,this.url=i.url,this.log=Log.of(this.emitter),this.verb=i.verb,this.metadata=e({},i.metadata||{}),this.rq=i.rq||r,this.events=i.events||[],this.required_keys=i.required_keys||[],this.optional_keys=i.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Tracker.assert_emitter_api(this.emitter),void 0===Tracker.verb[this.verb])throw new Error(`invalid HTTP verb[${this.verb}] passed`);if("string"!=typeof this.url)throw new Error(`invalid API url[${this.url}] passed`);Tracker.TRACKERS.push(this),o.events.forEach(t=>{Tracker.create_listener(this,t,(r={})=>{const i=e(o.metadata,{event_type:t},r.data||r),a=function(e,t){return e.replace(n,r=>{const n=r.slice(1,r.length);return n in t?t[n].toString():(console.warn(`\n preparing url[${e}] failed\n\n parameter[${n}] not detected in params:\n\n ${JSON.stringify(t,null,2)}\n `),r)})}(o.url,i),s=Tracker.pluck_valid_keys(o,i),u=Tracker.ensure_required_keys(o,s);if(u.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${u}\n payload:\n ${JSON.stringify(s,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[a,this.verb,s])})})}destroy(){this.listeners.forEach(([e,t])=>{var r;return null===(r=this.emitter)||void 0===r?void 0:r.removeEventListener(e,t)}),delete this.rq,delete this.emitter,t(Tracker.TRACKERS,this)}put(e={}){return Tracker.merge_metadata(this,e),this}}Tracker.TRACKERS=[],Tracker.QUEUE=r,Tracker.verb=i,function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",e[e.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(o||(o={}));const a=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,t){return!!~a.indexOf(e)||e.indexOf(t)===e.length-t.length}s.check_whitelist=function(e){return!!~a.indexOf(e)};function u(e){this.message=e}u.prototype=new Error,u.prototype.name="InvalidCharacterError";var c="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var d=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(c(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return c(t)}};function l(e){this.message=e}l.prototype=new Error,l.prototype.name="InvalidTokenError";var f=function(e,t){if("string"!=typeof e)throw new l("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(d(e.split(".")[r]))}catch(e){throw new l("Invalid token specified: "+e.message)}};f.InvalidTokenError=l;const p="production";function _(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=f(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&_.validate(r),r}function h(e){return{grant:e,is_granted:t=>(e&t)===t}}function m(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}_.validate=function(e){if("string"==typeof e&&(e=_(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===p.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=s.bind(null,t);if("dev"!==p.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==p.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},_.id=function(e){if(e)return"string"==typeof e&&(e=_(e)),e.data.id},h.of=h,h.from_token=function(e){const t=_(e,{require_valid_token:!0});return h.of(t.data.acl)},h.permissions=o;var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var y="ping",k="display",g="view";const w=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],E=["created","position"],T=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function R(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,r){return Math.floor(r*t*1e3)/1e3}))}}(e.duration))}function q(e,t,r){if(!t.segment_duration&&!R(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:A(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,r);0!=n.length&&e.emit(y,{position:n})}function A(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function S(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}var O;const b="vod",N="live",Q=[k,y,g];function x(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(y,{position:60*t.ticks}))}(e,t);case"vod":return q(e,t,"boolean"==typeof r&&r)}}function L(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}const I=((O=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:void 0,ttl:6e3,task:()=>{x(r,n.ticker)}};const o={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.25.0"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:Q,required_keys:w,optional_keys:T.concat(E).slice(0),metadata:o});r.on("reap",(function(){a&&a.destroy()})),r.on("config",(function(t){if(!a)return;const i=m(t,"data.metadata",{});if(!i.media_id)return;const o=m(a,"metadata.media_id");if(o&&i.media_id==o)return;const s=m(e,"analytics",{});a.put(i),a.put(s);const u=m(e,"metadata.live_start_time",e.live)?N:b;a.put({video_type:u,source:e.source||S()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(k)}));let s=0;r.on("playing",(function(){if(!a)return;if(s||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,n))return;a.put({muted:r.muted});const e=L(r);if(e)return s=Promise.resolve(e).then((function(){n.last_media_id=a.metadata.media_id,r.emit(g),s=0})).catch((function(){s=0}));n.last_media_id=a.metadata.media_id,r.emit(g)})),r.on("timeupdate",(function(){var t;a&&(s||L(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&x(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=void 0,e}(t)}),t.ttl))))})),r.on("seeked",(function(){a&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){R(e,t),t.last_idx=A(e,t)}(r,n.ticker)})),r.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,x(e,t.ticker))}(r,n)}))}}).pluginName="analytics",O);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}("undefined"!=typeof window?window:void 0!==v?v:{},I)}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.analytics=t())}(this,(function(){"use strict";const e=(...e)=>e.reduce((e,t)=>Object.assign(Object.assign({},e),t),{}),t=(e,t)=>{const r=e.lastIndexOf(t);return~r&&e.splice(r,1),e};class RequestQueue{static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return e;if(RequestQueue.is_high_water(e))return e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,r,n]){if(Date.now()<e.stats.ttl)return;const i=new XMLHttpRequest;e.open.push(i),i.timeout=RequestQueue.REQUEST_TIMEOUT_MS,i.ontimeout=function(){RequestQueue.handle_error(e,i)},i.onerror=function(t){RequestQueue.handle_error(e,i)},i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,i),Math.floor(i.status/100)},i.onload=function(){RequestQueue.rm(e,i),e.stats.failures&&e.stats.failures--},i.open(r,t),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{i.send(JSON.stringify(n))}catch(e){}}static rpush(e,...t){return t.forEach(t=>{e.pending.length>=RequestQueue.MAX_PENDING||(e.pending.push(t),RequestQueue.maybe_spawn_req(e))}),e}static lpop(e){return e.pending.shift()}static rm(e,r){return t(e.open,r),e}constructor(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.MAX_PENDING=5,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;var r=RequestQueue.of();const n=/:([a-zA-Z_]+)/g;class Log{static prepare(e,t){const r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r}static of(e){return new Log(e)}constructor(e){this.emitter=e}info(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.INFO,e))}error(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.ERROR,e))}warn(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.WARN,e))}}var i,o;Log.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},function(e){e.POST="POST",e.PUT="PUT",e.GET="GET"}(i||(i={}));class Tracker{static of(e,t){return new Tracker(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(t,r){return((t,...r)=>Object.keys(t).filter(e=>~r.indexOf(e)).reduce((r,n)=>e(r,{[n]:t[n]}),{}))(r,...t.valid_keys)}static merge_metadata(t,r={}){return t.metadata=Tracker.pluck_valid_keys(t,e(t.metadata,r)),t}static assert_emitter_api(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")}static create_listener(e,t,r){var n;e.listeners.push([t,r]),null===(n=e.emitter)||void 0===n||n.addEventListener(t,r)}constructor(t,i={}){const o=this;if(this.emitter=t,this.url=i.url,this.log=Log.of(this.emitter),this.verb=i.verb,this.metadata=e({},i.metadata||{}),this.rq=i.rq||r,this.events=i.events||[],this.required_keys=i.required_keys||[],this.optional_keys=i.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Tracker.assert_emitter_api(this.emitter),void 0===Tracker.verb[this.verb])throw new Error(`invalid HTTP verb[${this.verb}] passed`);if("string"!=typeof this.url)throw new Error(`invalid API url[${this.url}] passed`);Tracker.TRACKERS.push(this),o.events.forEach(t=>{Tracker.create_listener(this,t,(r={})=>{const i=e(o.metadata,{event_type:t},r.data||r),a=function(e,t){return e.replace(n,r=>{const n=r.slice(1,r.length);return n in t?t[n].toString():(console.warn(`\n preparing url[${e}] failed\n\n parameter[${n}] not detected in params:\n\n ${JSON.stringify(t,null,2)}\n `),r)})}(o.url,i),s=Tracker.pluck_valid_keys(o,i),u=Tracker.ensure_required_keys(o,s);if(u.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${u}\n payload:\n ${JSON.stringify(s,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[a,this.verb,s])})})}destroy(){this.listeners.forEach(([e,t])=>{var r;return null===(r=this.emitter)||void 0===r?void 0:r.removeEventListener(e,t)}),delete this.rq,delete this.emitter,t(Tracker.TRACKERS,this)}put(e={}){return Tracker.merge_metadata(this,e),this}}Tracker.TRACKERS=[],Tracker.QUEUE=r,Tracker.verb=i,function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",e[e.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(o||(o={}));const a=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,t){return!!~a.indexOf(e)||e.indexOf(t)===e.length-t.length}s.check_whitelist=function(e){return!!~a.indexOf(e)};function u(e){this.message=e}u.prototype=new Error,u.prototype.name="InvalidCharacterError";var c="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var d=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(c(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return c(t)}};function l(e){this.message=e}l.prototype=new Error,l.prototype.name="InvalidTokenError";var f=function(e,t){if("string"!=typeof e)throw new l("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(d(e.split(".")[r]))}catch(e){throw new l("Invalid token specified: "+e.message)}};f.InvalidTokenError=l;const p="production";function _(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=f(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&_.validate(r),r}function h(e){return{grant:e,is_granted:t=>(e&t)===t}}function m(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}_.validate=function(e){if("string"==typeof e&&(e=_(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===p.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=s.bind(null,t);if("dev"!==p.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==p.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},_.id=function(e){if(e)return"string"==typeof e&&(e=_(e)),e.data.id},h.of=h,h.from_token=function(e){const t=_(e,{require_valid_token:!0});return h.of(t.data.acl)},h.permissions=o;var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var y="ping",k="display",g="view";const w=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],E=["created","position"],T=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function R(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,r){return Math.floor(r*t*1e3)/1e3}))}}(e.duration))}function q(e,t,r){if(!t.segment_duration&&!R(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:A(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,r);0!=n.length&&e.emit(y,{position:n})}function A(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function S(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}var O;const b="vod",N="live",Q=[k,y,g];function x(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(y,{position:60*t.ticks}))}(e,t);case"vod":return q(e,t,"boolean"==typeof r&&r)}}function L(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}const I=((O=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:void 0,ttl:6e3,task:()=>{x(r,n.ticker)}};const o={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.26.0-rc"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:Q,required_keys:w,optional_keys:T.concat(E).slice(0),metadata:o});r.on("reap",(function(){a&&a.destroy()})),r.on("config",(function(t){if(!a)return;const i=m(t,"data.metadata",{});if(!i.media_id)return;const o=m(a,"metadata.media_id");if(o&&i.media_id==o)return;const s=m(e,"analytics",{});a.put(i),a.put(s);const u=m(e,"metadata.live_start_time",e.live)?N:b;a.put({video_type:u,source:e.source||S()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(k)}));let s=0;r.on("playing",(function(){if(!a)return;if(s||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,n))return;a.put({muted:r.muted});const e=L(r);if(e)return s=Promise.resolve(e).then((function(){n.last_media_id=a.metadata.media_id,r.emit(g),s=0})).catch((function(){s=0}));n.last_media_id=a.metadata.media_id,r.emit(g)})),r.on("timeupdate",(function(){var t;a&&(s||L(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&x(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=void 0,e}(t)}),t.ttl))))})),r.on("seeked",(function(){a&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){R(e,t),t.last_idx=A(e,t)}(r,n.ticker)})),r.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,x(e,t.ticker))}(r,n)}))}}).pluginName="analytics",O);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}("undefined"!=typeof window?window:void 0!==v?v:{},I)}));
|
package/plugins/rts.d.ts
CHANGED
|
@@ -872,10 +872,15 @@ declare const NO_DVR = "no-timeline";
|
|
|
872
872
|
|
|
873
873
|
/* Excluded from this release type: NQState */
|
|
874
874
|
|
|
875
|
+
/**
|
|
876
|
+
* @public
|
|
877
|
+
*/
|
|
878
|
+
export declare type OnStats = OnStats_2;
|
|
879
|
+
|
|
875
880
|
/**
|
|
876
881
|
* Represents the parsed WebRTC statistics collected.
|
|
877
882
|
*/
|
|
878
|
-
declare interface
|
|
883
|
+
declare interface OnStats_2 {
|
|
879
884
|
/** Gets the time at which the statistics were collected as a string value in ISO format. */
|
|
880
885
|
timestamp: string;
|
|
881
886
|
/** List of audio & video output statistics. */
|
|
@@ -1514,6 +1519,8 @@ declare type RecommendationsReadyEventDetail = {
|
|
|
1514
1519
|
playlist: RecommendationItem[];
|
|
1515
1520
|
};
|
|
1516
1521
|
|
|
1522
|
+
declare const RECORD = "health:record";
|
|
1523
|
+
|
|
1517
1524
|
/**
|
|
1518
1525
|
* @public
|
|
1519
1526
|
* emitted when an Error recovery is attempted
|
|
@@ -1579,12 +1586,7 @@ declare const RTL = "is-rtl";
|
|
|
1579
1586
|
declare const RTS: PluginCtor<NoInfer<RTSConfig>, NoInfer<RTSPlayer>> & NoInfer<RTSAPI>;
|
|
1580
1587
|
export default RTS;
|
|
1581
1588
|
|
|
1582
|
-
|
|
1583
|
-
readonly log: Logger;
|
|
1584
|
-
load(): void;
|
|
1585
|
-
stop(): void;
|
|
1586
|
-
getRTCPeerConnection(): RTCPeerConnection | undefined;
|
|
1587
|
-
}
|
|
1589
|
+
/* Excluded from this release type: RTSAdapter */
|
|
1588
1590
|
|
|
1589
1591
|
/**
|
|
1590
1592
|
* @public
|
|
@@ -1630,8 +1632,11 @@ export declare type RTSPlayer = PlayerWith<{
|
|
|
1630
1632
|
/* Excluded from this release type: emit */
|
|
1631
1633
|
/* Excluded from this release type: emit */
|
|
1632
1634
|
/* Excluded from this release type: emit */
|
|
1635
|
+
/* Excluded from this release type: emit */
|
|
1633
1636
|
}>;
|
|
1634
1637
|
|
|
1638
|
+
/* Excluded from this release type: RTSRecordDetail */
|
|
1639
|
+
|
|
1635
1640
|
/**
|
|
1636
1641
|
* @public
|
|
1637
1642
|
*/
|
package/plugins/rts.js
CHANGED
|
@@ -22,4 +22,4 @@ function(e,t){var r=Mt,n=r.Buffer;function s(e,t){for(var r in e)t[r]=e[r]}funct
|
|
|
22
22
|
* License: MIT
|
|
23
23
|
*/(n))}this.layers=void 0,this.player.emit("qualities",[])}_observe(){var e;null===(e=this.engine)||void 0===e||e.on("broadcastEvent",e=>{const{name:t,data:r}=e;switch(t){case"active":return this._handleActive(r);case"viewercount":return this._handleViewerCount(r.viewercount);case"layers":return this._handleQualityLayers(r.medias);case"inactive":return this._handleInactive()}})}async _connect(){const e=this.engine;e&&await e.connect(MillicastAdapter.Options)}getRTCPeerConnection(){var e;return null===(e=this.engine)||void 0===e?void 0:e.getRTCPeerConnection()}}function po(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function mo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?po(Object(r),!0).forEach((function(t){bo(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):po(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function go(e,t,r,n,s,i,o){try{var a=e[i](o),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,s)}function yo(e){return function(){var t=this,r=arguments;return new Promise((function(n,s){var i=e.apply(t,r);function o(e){go(i,n,s,o,a,"next",e)}function a(e){go(i,n,s,o,a,"throw",e)}o(void 0)}))}}function bo(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vo(){}function wo(){wo.init.call(this)}function So(e){return void 0===e._maxListeners?wo.defaultMaxListeners:e._maxListeners}function Ro(e,t,r){if(t)e.call(r);else for(var n=e.length,s=Lo(e,n),i=0;i<n;++i)s[i].call(r)}function xo(e,t,r,n){if(t)e.call(r,n);else for(var s=e.length,i=Lo(e,s),o=0;o<s;++o)i[o].call(r,n)}function ko(e,t,r,n,s){if(t)e.call(r,n,s);else for(var i=e.length,o=Lo(e,i),a=0;a<i;++a)o[a].call(r,n,s)}function _o(e,t,r,n,s,i){if(t)e.call(r,n,s,i);else for(var o=e.length,a=Lo(e,o),c=0;c<o;++c)a[c].call(r,n,s,i)}function Co(e,t,r,n){if(t)e.apply(r,n);else for(var s=e.length,i=Lo(e,s),o=0;o<s;++o)i[o].apply(r,n)}function Io(e,t,r,n){var s,i,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]):(i=e._events=new vo,e._eventsCount=0),o){if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(s=So(e))&&s>0&&o.length>s){o.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=i[t]=r,++e._eventsCount;return e}function Eo(e,t,r){var n=!1;function s(){e.removeListener(t,s),n||(n=!0,r.apply(e,arguments))}return s.listener=r,s}function To(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Lo(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/rts",MillicastAdapter.Options={events:["active","inactive","viewercount","layers"]},MillicastAdapter.WOWZA_DIRECTOR_ENDPOINT="https://realtime1.wowza.com",vo.prototype=Object.create(null),wo.EventEmitter=wo,wo.usingDomains=!1,wo.prototype.domain=void 0,wo.prototype._events=void 0,wo.prototype._maxListeners=void 0,wo.defaultMaxListeners=10,wo.init=function(){this.domain=null,wo.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new vo,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},wo.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},wo.prototype.getMaxListeners=function(){return So(this)},wo.prototype.emit=function(e){var t,r,n,s,i,o,a,c="error"===e;if(o=this._events)c=c&&null==o.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=o[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:Ro(r,u,this);break;case 2:xo(r,u,this,arguments[1]);break;case 3:ko(r,u,this,arguments[1],arguments[2]);break;case 4:_o(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(s=Array(n-1),i=1;i<n;i++)s[i-1]=arguments[i];Co(r,u,this,s)}return!0},wo.prototype.addListener=function(e,t){return Io(this,e,t,!1)},wo.prototype.on=wo.prototype.addListener,wo.prototype.prependListener=function(e,t){return Io(this,e,t,!0)},wo.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Eo(this,e,t)),this},wo.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Eo(this,e,t)),this},wo.prototype.removeListener=function(e,t){var r,n,s,i,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new vo:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,i=r.length;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new vo,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,s=e.length;n<s;r+=1,n+=1)e[r]=e[n];e.pop()}(r,s);n.removeListener&&this.emit("removeListener",e,o||t)}return this},wo.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new vo,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new vo:delete r[e]),this;if(0===arguments.length){for(var n,s=Object.keys(r),i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new vo,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},wo.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},wo.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):To.call(e,t)},wo.prototype.listenerCount=To,wo.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Ao=window.RTCPeerConnection,Mo=window.RTCIceCandidate,Po=window.RTCSessionDescription;class b extends wo{constructor(e){super(),bo(this,"pc",void 0),this.pc=new Ao({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Po(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Po(e))}createAnswer(){var e=this;return yo((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return yo((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new Mo(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,bo(this,"ws",null),bo(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return yo((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(mo(mo({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Oo="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",Do=["vp9","vp8","h264","red","ulpfec","rtx"],Fo=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,bo(this,"audioIndex",-1),bo(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,s=r>>8&255,i=255&r;return n>66?(n=66,s=224,i=31):0===s&&(s=224),"profile-level-id=".concat((n<<16|s<<8|i).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,s=null,i=()=>"m=audio"===s?n:"m=video"===s?r:null,o=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var o="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==o&&"chrome"===Oo){var[a,c,l]=e.split(" ");return"".concat(a," ").concat(c," ").concat(l," ").concat(o)}s=t;break;case"a=rtpmap":var u=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!u||"chrome"!==Oo)break;var d=u[2].toLowerCase();r.bitRate&&Do.includes(d)&&(e+="\r\na=fmtp:".concat(u[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&Fo.includes(d)&&(e+="\r\na=fmtp:".concat(u[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var h=i();if(null!=h&&h.bitRate&&["firefox","safari"].includes(Oo)){var f=1e3*h.bitRate;e+="\r\nb=TIAS:".concat(.95*f-16e3),e+="\r\nb=AS:".concat(f),e+="\r\nb=CT:".concat(f)}break;case"a=mid":var p=i();p&&"chrome"===Oo&&(p.bitRate&&(e+="\r\nb=CT:".concat(p.bitRate),e+="\r\nb=AS:".concat(p.bitRate),"frameRate"in p&&p.frameRate&&(e+="\r\na=framerate:".concat(p.frameRate.toFixed(2)))),s=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:o}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,s]=r[1].split(" ");if(!s.startsWith("http")&&!s.startsWith("ur")){var i=parseInt(n,10),o=t.get(i)||[];return o.push(e),t.set(i,o),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[s,i]=n;return"audio"===t?this.audioIndex=s:this.videoIndex=s,"VP8"!==e&&"VP9"!==e?i:i.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,s=e.length;n<s;++n){var i=e[n];if(i.startsWith("m=audio"))r="audio";else if(i.startsWith("m=video"))r="video";else if("a=rtcp-mux"===i&&"audio"===r){var o=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...o);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),s=!1;if(!r&&!n)return e;var i=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!s&&"a=rtcp-rsize"===e)return s=!0,[e].concat(i).join("\r\n")}else if("a=rtcp-mux"===e){if(s)return[e].concat(i).join("\r\n");s=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends wo{constructor(e,t){super(),this.video=e,bo(this,"sdpUrl",""),bo(this,"applicationName",""),bo(this,"streamName",""),bo(this,"userData",null),bo(this,"sdpHandler",void 0),bo(this,"secureToken",void 0),bo(this,"constraints",{audio:!0,video:!0}),bo(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),bo(this,"audioConfigs",{codec:"opus",bitRate:64}),bo(this,"iceServers",[]),bo(this,"mediaStream",null),bo(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return yo((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return yo((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),s=t.createPeerConnection();s.on("addstream",t.attachStream.bind(t)),yield s.setRemoteDescription(n);var i=yield s.createAnswer(),o=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(i,e=>o.transformPlay(e),"play"):o.transformPlay(i);yield s.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{s.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return yo((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),s=t.createPeerConnection();s.attachMediaStream(n);var i=new S(t.videoConfigs,t.audioConfigs),o=yield s.createOffer(),a=t.sdpHandler?t.sdpHandler(o,e=>i.transformPublish(e),"publish"):i.transformPublish(o);yield s.setLocalDescription(a);var{sdp:c,iceCandidates:l}=yield r.sendOffer(a);yield s.setRemoteDescription(c),l.forEach(e=>{s.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return yo((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{static wants(e){return e.type==WowzaWebRTCAdapter.Type}constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n,this.hasReportedError=!1}async load(){this.log("loading",this.src.streamName),this.player.original_src=this.src.sdpUrl,this.engine=new x(this.player,this.src),await this.playRemote()}retry(){!1!==this.player.opts.retry&&setTimeout(()=>{0!=this.player.reaper&&this.engine&&this.playRemote()},3e3)}async playRemote(){var e;if(this.engine)try{await this.engine.playRemote(),this.player.emit("recover")}catch(t){if(this.retry(),this.hasReportedError)return;this.player.emit("error",null!==(e=t)&&void 0!==e?e:{fatal:!1,message:"failed to connect to stream"}),this.hasReportedError=!0}}stop(){var e;null===(e=this.engine)||void 0===e||e.stop(),this.engine=void 0}getRTCPeerConnection(){var e;return(null===(e=this.engine)||void 0===e?void 0:e.getPeerConnection())||void 0}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";
|
|
24
24
|
/*! For license information please see webrtc-stats.js.LICENSE.txt */
|
|
25
|
-
var jo=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){!function(t,r){e.exports=r()}(self,()=>{return e={7:e=>{var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function s(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}m(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,{once:!0})}(e,s)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var s,i,o,l;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]),void 0===o)o=i[t]=r,++e._eventsCount;else if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=u.bind(n);return s.listener=r,n.wrapFn=s,s}function h(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):p(s,s.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function m(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(i){n.once&&e.removeEventListener(t,s),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,i=this._events;if(void 0!==i)s=s&&void 0===i.error;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=p(c,l);for(r=0;r<l;++r)n(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return l(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return l(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,s,i,o;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(s=i[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},586:function(e,t,r){var n,s;!function(i){var o,a={VERSION:"1.6.1"},c={},l=function(e,t){return function(){return t.apply(e,arguments)}},u=function(){var e,t,r=arguments,n=r[0];for(t=1;t<r.length;t++)for(e in r[t])!(e in n)&&r[t].hasOwnProperty(e)&&(n[e]=r[t][e]);return n},d=function(e,t){return{value:e,name:t}};a.TRACE=d(1,"TRACE"),a.DEBUG=d(2,"DEBUG"),a.INFO=d(3,"INFO"),a.TIME=d(4,"TIME"),a.WARN=d(5,"WARN"),a.ERROR=d(8,"ERROR"),a.OFF=d(99,"OFF");var h=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};h.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var t=this.context.filterLevel;return e.value>=t.value},trace:function(){this.invoke(a.TRACE,arguments)},debug:function(){this.invoke(a.DEBUG,arguments)},info:function(){this.invoke(a.INFO,arguments)},warn:function(){this.invoke(a.WARN,arguments)},error:function(){this.invoke(a.ERROR,arguments)},time:function(e){"string"==typeof e&&e.length>0&&this.invoke(a.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&e.length>0&&this.invoke(a.TIME,[e,"end"])},invoke:function(e,t){o&&this.enabledFor(e)&&o(t,u({level:e},this.context))}};var f,p=new h({filterLevel:a.OFF});(f=a).enabledFor=l(p,p.enabledFor),f.trace=l(p,p.trace),f.debug=l(p,p.debug),f.time=l(p,p.time),f.timeEnd=l(p,p.timeEnd),f.info=l(p,p.info),f.warn=l(p,p.warn),f.error=l(p,p.error),f.log=f.info,a.setHandler=function(e){o=e},a.setLevel=function(e){for(var t in p.setLevel(e),c)c.hasOwnProperty(t)&&c[t].setLevel(e)},a.getLevel=function(){return p.getLevel()},a.get=function(e){return c[e]||(c[e]=new h(u({name:e},p.context)))},a.createDefaultHandler=function(e){(e=e||{}).formatter=e.formatter||function(e,t){t.name&&e.unshift("["+t.name+"]")};var t={},r=function(e,t){Function.prototype.apply.call(e,console,t)};return"undefined"==typeof console?function(){}:function(n,s){n=Array.prototype.slice.call(n);var i,o=console.log;s.level===a.TIME?(i=(s.name?"["+s.name+"] ":"")+n[0],"start"===n[1]?console.time?console.time(i):t[i]=(new Date).getTime():console.timeEnd?console.timeEnd(i):r(o,[i+": "+((new Date).getTime()-t[i])+"ms"])):(s.level===a.WARN&&console.warn?o=console.warn:s.level===a.ERROR&&console.error?o=console.error:s.level===a.INFO&&console.info?o=console.info:s.level===a.DEBUG&&console.debug?o=console.debug:s.level===a.TRACE&&console.trace&&(o=console.trace),e.formatter(n,s),r(o,n))}},a.useDefaults=function(e){a.setLevel(e&&e.defaultLevel||a.DEBUG),a.setHandler(a.createDefaultHandler(e))},a.setDefaults=a.useDefaults,void 0===(s="function"==typeof(n=a)?n.call(t,r,t,e):n)||(e.exports=s)}()},156:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;var o=r(586);Object.defineProperty(t,"Logger",{enumerable:!0,get:function(){return i(o).default}}),s(r(284),t),s(r(280),t),s(r(738),t),s(r(767),t)},738:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.QualityLimitationReason=void 0,function(e){e[e.none=0]="none",e[e.cpu=1]="cpu",e[e.bandwidth=2]="bandwidth",e[e.other=3]="other"}(r||(t.QualityLimitationReason=r={}))},280:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},767:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.calculatePacketsLostRatio=t.calculateRate=t.getMediaKind=void 0,t.getMediaKind=e=>{let t=e.kind||e.mediaType;return["audio","video"].includes(t)||"inbound-rtp"!==e.type||(t=e.id.toLocaleLowerCase().includes("video")?"video":"audio"),t},t.calculateRate=(e,t,r,n)=>r&&n?(t-n)/((e-r)/1e3):0,t.calculatePacketsLostRatio=(e,t,r,n)=>0==t?0:(e-(null!=r?r:0))/(t-(null!=n?n:0))},284:function(e,t,r){var n,s,i,o,a,c,l,u,d,h,f,p,m,g,y,v,w=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},R=this&&this.__classPrivateFieldSet||function(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,r):s?s.value=r:t.set(e,r),r},k=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},_=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRTCStats=void 0;const I=r(7),E=_(r(586)),T=r(738),L=r(185);class P extends I.EventEmitter{constructor(e){super(),n.add(this),s.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,null),c.set(this,void 0),l.set(this,null),this.start=()=>{k(this,c,"f").info("WebRTC statistics collection is starting..."),R(this,l,null,"f"),R(this,a,setInterval(k(this,u,"f"),k(this,i,"f")),"f")},this.stop=()=>{k(this,a,"f")&&(clearInterval(k(this,a,"f")),R(this,a,null,"f"),k(this,c,"f").info("WebRTC statistics collection has stopped."))},u.set(this,()=>w(this,void 0,void 0,(function*(){let e,t;try{k(this,c,"f").trace("Requesting WebRTC statistics..."),e=yield k(this,s,"f").call(this),t=(new Date).toISOString()}catch(e){return k(this,c,"f").error("Problem collecting the WebRTC statistics.",e),void this.emit("error","Problem collecting the WebRTC statistics - "+e)}const r=Array.from(e.values()),i={timestamp:t,input:{audio:[],video:[]},output:{audio:[],video:[]}};k(this,o,"f")&&(i.rawStats=e);for(let t=0;t<Object.keys(r).length;t++){const s=r[t];switch(s.type){case"outbound-rtp":const t=s,r=(0,L.getMediaKind)(t);"audio"===r?yield k(this,n,"m",f).call(this,e,t,i):"video"===r&&(yield k(this,n,"m",p).call(this,e,t,i));break;case"inbound-rtp":const o=s;let a=(0,L.getMediaKind)(o);"audio"===a?yield k(this,n,"m",g).call(this,e,o,i):"video"===a&&(yield k(this,n,"m",y).call(this,e,o,i));break;case"candidate-pair":const c=s;c.nominated&&k(this,n,"m",v).call(this,c,i)}}R(this,l,i,"f"),this.emit("stats",i)}))),R(this,c,E.default.get("WebRTCStats"),"f"),R(this,s,e.getStats,"f"),R(this,i,e.getStatsInterval||1e3,"f"),R(this,o,!!e.includeRawStats,"f")}}t.WebRTCStats=P,s=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,n=new WeakSet,d=function(e,t){if(t){const r=e.get(t);if(r)return{mimeType:r.mimeType}}return{}},h=function(e,t,r){return w(this,void 0,void 0,(function*(){var s,i,o,a;const c=(0,L.calculateRate)(t.timestamp,t.bytesSent,null==r?void 0:r.timestamp,null==r?void 0:r.totalBytesSent),l=(0,L.calculateRate)(t.timestamp,t.packetsSent,null==r?void 0:r.timestamp,null==r?void 0:r.totalPacketsSent),u=k(this,n,"m",d).call(this,e,t.codecId);return Object.assign({id:t.id,timestamp:t.timestamp,mid:t.mid,totalBytesSent:t.bytesSent,bytesSentDelta:t.bytesSent-(null!==(s=null==r?void 0:r.totalBytesSent)&&void 0!==s?s:0),totalPacketsSent:t.packetsSent,packetsSentDelta:t.packetsSent-(null!==(i=null==r?void 0:r.totalPacketsSent)&&void 0!==i?i:0),bitrate:c,packetRate:l,targetBitrate:t.targetBitrate,retransmittedPacketsSent:t.retransmittedPacketsSent,retransmittedPacketsSentDelta:t.retransmittedPacketsSent-(null!==(o=null==r?void 0:r.retransmittedPacketsSent)&&void 0!==o?o:0),retransmittedBytesSent:t.retransmittedBytesSent,retransmittedBytesSentDelta:t.retransmittedBytesSent-(null!==(a=null==r?void 0:r.retransmittedBytesSent)&&void 0!==a?a:0)},u)}))},f=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.output.audio.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",h).call(this,e,t,i),a=Object.assign({},o);r.output.audio.push(a)}))},p=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.output.video.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",h).call(this,e,t,i);let a=T.QualityLimitationReason.none;t.qualityLimitationReason&&(a=t.qualityLimitationReason);const c=Object.assign(Object.assign({},o),{frameWidth:t.frameWidth,frameHeight:t.frameHeight,framesPerSecond:t.framesPerSecond,framesSent:t.framesSent,qualityLimitationReason:a,qualityLimitationDurations:t.qualityLimitationDurations});r.output.video.push(c)}))},m=function(e,t,r){return w(this,void 0,void 0,(function*(){var s,i;const o=(0,L.calculateRate)(t.timestamp,t.bytesReceived,null==r?void 0:r.timestamp,null==r?void 0:r.totalBytesReceived),a=(0,L.calculateRate)(t.timestamp,t.packetsReceived,null==r?void 0:r.timestamp,null==r?void 0:r.totalPacketsReceived),c=(0,L.calculatePacketsLostRatio)(t.packetsReceived,t.packetsLost,null==r?void 0:r.totalPacketsReceived,null==r?void 0:r.totalPacketsLost),l=(null!==(s=t.packetsLost)&&void 0!==s?s:0)-(null!==(i=null==r?void 0:r.totalPacketsLost)&&void 0!==i?i:0),u=k(this,n,"m",d).call(this,e,t.codecId);return Object.assign({id:t.id,timestamp:t.timestamp,mid:t.mid,trackIdentifier:t.trackIdentifier,jitter:t.jitter,jitterBufferDelay:t.jitterBufferDelay,jitterBufferEmittedCount:t.jitterBufferEmittedCount,totalBytesReceived:t.bytesReceived,totalPacketsReceived:t.packetsReceived,totalPacketsLost:t.packetsLost,bitrate:o,packetRate:a,packetLossRatio:c,packetLossDelta:l},u)}))},g=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.input.audio.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",m).call(this,e,t,i);r.input.audio.push(o)}))},y=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.input.video.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",m).call(this,e,t,i),a=Object.assign(Object.assign({},o),{keyFramesDecoded:t.keyFramesDecoded,frameHeight:t.frameHeight,frameWidth:t.frameWidth,framesDecoded:t.framesDecoded,framesDropped:t.framesDropped,framesPerSecond:t.framesPerSecond,framesReceived:t.framesReceived});r.input.video.push(a)}))},v=function(e,t){t.totalRoundTripTime=e.totalRoundTripTime,t.currentRoundTripTime=e.currentRoundTripTime,t.responsesReceived=e.responsesReceived,t.availableOutgoingBitrate=e.availableOutgoingBitrate,t.availableIncomingBitrate=e.availableIncomingBitrate}}},t={},function r(n){var s=t[n];if(void 0!==s)return s.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(156);var e,t})}));class RTSLoader{constructor(){this.log=t("rts"),this.stats=new jo.WebRTCStats({getStatsInterval:5e3,getStats:()=>{var e,t;return(null===(t=null===(e=this.engine)||void 0===e?void 0:e.getRTCPeerConnection())||void 0===t?void 0:t.getStats())||Promise.resolve(new Map)}})}stop(){var e,t;null===(e=this.engine)||void 0===e||e.stop(),null===(t=this.stats)||void 0===t||t.stop()}init(e,t,r){r.on("reap",()=>this.stop()),r.on("src",()=>{this.engine&&(this.stop(),r.srcObject=null,this.engine=void 0)}),this.stats.on("stats",e=>{r.emit(Zo.events.STATS,{stats:e})})}onload(e,t,r,n){var s;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(s=this.engine)||void 0===s||s.load(),this.stats.start()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}RTSLoader.pluginName="rts",RTSLoader.events=fo,RTSLoader.state=ho;const Zo=function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}(window,RTSLoader);return Zo}));
|
|
25
|
+
var jo=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){!function(t,r){e.exports=r()}(self,()=>{return e={7:e=>{var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function s(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}m(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,{once:!0})}(e,s)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var s,i,o,l;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]),void 0===o)o=i[t]=r,++e._eventsCount;else if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=u.bind(n);return s.listener=r,n.wrapFn=s,s}function h(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):p(s,s.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function m(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(i){n.once&&e.removeEventListener(t,s),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,i=this._events;if(void 0!==i)s=s&&void 0===i.error;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=p(c,l);for(r=0;r<l;++r)n(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return l(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return l(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,s,i,o;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(s=i[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},586:function(e,t,r){var n,s;!function(i){var o,a={VERSION:"1.6.1"},c={},l=function(e,t){return function(){return t.apply(e,arguments)}},u=function(){var e,t,r=arguments,n=r[0];for(t=1;t<r.length;t++)for(e in r[t])!(e in n)&&r[t].hasOwnProperty(e)&&(n[e]=r[t][e]);return n},d=function(e,t){return{value:e,name:t}};a.TRACE=d(1,"TRACE"),a.DEBUG=d(2,"DEBUG"),a.INFO=d(3,"INFO"),a.TIME=d(4,"TIME"),a.WARN=d(5,"WARN"),a.ERROR=d(8,"ERROR"),a.OFF=d(99,"OFF");var h=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};h.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var t=this.context.filterLevel;return e.value>=t.value},trace:function(){this.invoke(a.TRACE,arguments)},debug:function(){this.invoke(a.DEBUG,arguments)},info:function(){this.invoke(a.INFO,arguments)},warn:function(){this.invoke(a.WARN,arguments)},error:function(){this.invoke(a.ERROR,arguments)},time:function(e){"string"==typeof e&&e.length>0&&this.invoke(a.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&e.length>0&&this.invoke(a.TIME,[e,"end"])},invoke:function(e,t){o&&this.enabledFor(e)&&o(t,u({level:e},this.context))}};var f,p=new h({filterLevel:a.OFF});(f=a).enabledFor=l(p,p.enabledFor),f.trace=l(p,p.trace),f.debug=l(p,p.debug),f.time=l(p,p.time),f.timeEnd=l(p,p.timeEnd),f.info=l(p,p.info),f.warn=l(p,p.warn),f.error=l(p,p.error),f.log=f.info,a.setHandler=function(e){o=e},a.setLevel=function(e){for(var t in p.setLevel(e),c)c.hasOwnProperty(t)&&c[t].setLevel(e)},a.getLevel=function(){return p.getLevel()},a.get=function(e){return c[e]||(c[e]=new h(u({name:e},p.context)))},a.createDefaultHandler=function(e){(e=e||{}).formatter=e.formatter||function(e,t){t.name&&e.unshift("["+t.name+"]")};var t={},r=function(e,t){Function.prototype.apply.call(e,console,t)};return"undefined"==typeof console?function(){}:function(n,s){n=Array.prototype.slice.call(n);var i,o=console.log;s.level===a.TIME?(i=(s.name?"["+s.name+"] ":"")+n[0],"start"===n[1]?console.time?console.time(i):t[i]=(new Date).getTime():console.timeEnd?console.timeEnd(i):r(o,[i+": "+((new Date).getTime()-t[i])+"ms"])):(s.level===a.WARN&&console.warn?o=console.warn:s.level===a.ERROR&&console.error?o=console.error:s.level===a.INFO&&console.info?o=console.info:s.level===a.DEBUG&&console.debug?o=console.debug:s.level===a.TRACE&&console.trace&&(o=console.trace),e.formatter(n,s),r(o,n))}},a.useDefaults=function(e){a.setLevel(e&&e.defaultLevel||a.DEBUG),a.setHandler(a.createDefaultHandler(e))},a.setDefaults=a.useDefaults,void 0===(s="function"==typeof(n=a)?n.call(t,r,t,e):n)||(e.exports=s)}()},156:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;var o=r(586);Object.defineProperty(t,"Logger",{enumerable:!0,get:function(){return i(o).default}}),s(r(284),t),s(r(280),t),s(r(738),t),s(r(767),t)},738:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.QualityLimitationReason=void 0,function(e){e[e.none=0]="none",e[e.cpu=1]="cpu",e[e.bandwidth=2]="bandwidth",e[e.other=3]="other"}(r||(t.QualityLimitationReason=r={}))},280:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},767:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.calculatePacketsLostRatio=t.calculateRate=t.getMediaKind=void 0,t.getMediaKind=e=>{let t=e.kind||e.mediaType;return["audio","video"].includes(t)||"inbound-rtp"!==e.type||(t=e.id.toLocaleLowerCase().includes("video")?"video":"audio"),t},t.calculateRate=(e,t,r,n)=>r&&n?(t-n)/((e-r)/1e3):0,t.calculatePacketsLostRatio=(e,t,r,n)=>0==t?0:(e-(null!=r?r:0))/(t-(null!=n?n:0))},284:function(e,t,r){var n,s,i,o,a,c,l,u,d,h,f,p,m,g,y,v,w=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},R=this&&this.__classPrivateFieldSet||function(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,r):s?s.value=r:t.set(e,r),r},k=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},_=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRTCStats=void 0;const I=r(7),E=_(r(586)),T=r(738),L=r(185);class P extends I.EventEmitter{constructor(e){super(),n.add(this),s.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,null),c.set(this,void 0),l.set(this,null),this.start=()=>{k(this,c,"f").info("WebRTC statistics collection is starting..."),R(this,l,null,"f"),R(this,a,setInterval(k(this,u,"f"),k(this,i,"f")),"f")},this.stop=()=>{k(this,a,"f")&&(clearInterval(k(this,a,"f")),R(this,a,null,"f"),k(this,c,"f").info("WebRTC statistics collection has stopped."))},u.set(this,()=>w(this,void 0,void 0,(function*(){let e,t;try{k(this,c,"f").trace("Requesting WebRTC statistics..."),e=yield k(this,s,"f").call(this),t=(new Date).toISOString()}catch(e){return k(this,c,"f").error("Problem collecting the WebRTC statistics.",e),void this.emit("error","Problem collecting the WebRTC statistics - "+e)}const r=Array.from(e.values()),i={timestamp:t,input:{audio:[],video:[]},output:{audio:[],video:[]}};k(this,o,"f")&&(i.rawStats=e);for(let t=0;t<Object.keys(r).length;t++){const s=r[t];switch(s.type){case"outbound-rtp":const t=s,r=(0,L.getMediaKind)(t);"audio"===r?yield k(this,n,"m",f).call(this,e,t,i):"video"===r&&(yield k(this,n,"m",p).call(this,e,t,i));break;case"inbound-rtp":const o=s;let a=(0,L.getMediaKind)(o);"audio"===a?yield k(this,n,"m",g).call(this,e,o,i):"video"===a&&(yield k(this,n,"m",y).call(this,e,o,i));break;case"candidate-pair":const c=s;c.nominated&&k(this,n,"m",v).call(this,c,i)}}R(this,l,i,"f"),this.emit("stats",i)}))),R(this,c,E.default.get("WebRTCStats"),"f"),R(this,s,e.getStats,"f"),R(this,i,e.getStatsInterval||1e3,"f"),R(this,o,!!e.includeRawStats,"f")}}t.WebRTCStats=P,s=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,n=new WeakSet,d=function(e,t){if(t){const r=e.get(t);if(r)return{mimeType:r.mimeType}}return{}},h=function(e,t,r){return w(this,void 0,void 0,(function*(){var s,i,o,a;const c=(0,L.calculateRate)(t.timestamp,t.bytesSent,null==r?void 0:r.timestamp,null==r?void 0:r.totalBytesSent),l=(0,L.calculateRate)(t.timestamp,t.packetsSent,null==r?void 0:r.timestamp,null==r?void 0:r.totalPacketsSent),u=k(this,n,"m",d).call(this,e,t.codecId);return Object.assign({id:t.id,timestamp:t.timestamp,mid:t.mid,totalBytesSent:t.bytesSent,bytesSentDelta:t.bytesSent-(null!==(s=null==r?void 0:r.totalBytesSent)&&void 0!==s?s:0),totalPacketsSent:t.packetsSent,packetsSentDelta:t.packetsSent-(null!==(i=null==r?void 0:r.totalPacketsSent)&&void 0!==i?i:0),bitrate:c,packetRate:l,targetBitrate:t.targetBitrate,retransmittedPacketsSent:t.retransmittedPacketsSent,retransmittedPacketsSentDelta:t.retransmittedPacketsSent-(null!==(o=null==r?void 0:r.retransmittedPacketsSent)&&void 0!==o?o:0),retransmittedBytesSent:t.retransmittedBytesSent,retransmittedBytesSentDelta:t.retransmittedBytesSent-(null!==(a=null==r?void 0:r.retransmittedBytesSent)&&void 0!==a?a:0)},u)}))},f=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.output.audio.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",h).call(this,e,t,i),a=Object.assign({},o);r.output.audio.push(a)}))},p=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.output.video.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",h).call(this,e,t,i);let a=T.QualityLimitationReason.none;t.qualityLimitationReason&&(a=t.qualityLimitationReason);const c=Object.assign(Object.assign({},o),{frameWidth:t.frameWidth,frameHeight:t.frameHeight,framesPerSecond:t.framesPerSecond,framesSent:t.framesSent,qualityLimitationReason:a,qualityLimitationDurations:t.qualityLimitationDurations});r.output.video.push(c)}))},m=function(e,t,r){return w(this,void 0,void 0,(function*(){var s,i;const o=(0,L.calculateRate)(t.timestamp,t.bytesReceived,null==r?void 0:r.timestamp,null==r?void 0:r.totalBytesReceived),a=(0,L.calculateRate)(t.timestamp,t.packetsReceived,null==r?void 0:r.timestamp,null==r?void 0:r.totalPacketsReceived),c=(0,L.calculatePacketsLostRatio)(t.packetsReceived,t.packetsLost,null==r?void 0:r.totalPacketsReceived,null==r?void 0:r.totalPacketsLost),l=(null!==(s=t.packetsLost)&&void 0!==s?s:0)-(null!==(i=null==r?void 0:r.totalPacketsLost)&&void 0!==i?i:0),u=k(this,n,"m",d).call(this,e,t.codecId);return Object.assign({id:t.id,timestamp:t.timestamp,mid:t.mid,trackIdentifier:t.trackIdentifier,jitter:t.jitter,jitterBufferDelay:t.jitterBufferDelay,jitterBufferEmittedCount:t.jitterBufferEmittedCount,totalBytesReceived:t.bytesReceived,totalPacketsReceived:t.packetsReceived,totalPacketsLost:t.packetsLost,bitrate:o,packetRate:a,packetLossRatio:c,packetLossDelta:l},u)}))},g=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.input.audio.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",m).call(this,e,t,i);r.input.audio.push(o)}))},y=function(e,t,r){return w(this,void 0,void 0,(function*(){var s;const i=null===(s=k(this,l,"f"))||void 0===s?void 0:s.input.video.find(e=>e.id===t.id);if(i&&t.timestamp-i.timestamp<=0)return;const o=yield k(this,n,"m",m).call(this,e,t,i),a=Object.assign(Object.assign({},o),{keyFramesDecoded:t.keyFramesDecoded,frameHeight:t.frameHeight,frameWidth:t.frameWidth,framesDecoded:t.framesDecoded,framesDropped:t.framesDropped,framesPerSecond:t.framesPerSecond,framesReceived:t.framesReceived});r.input.video.push(a)}))},v=function(e,t){t.totalRoundTripTime=e.totalRoundTripTime,t.currentRoundTripTime=e.currentRoundTripTime,t.responsesReceived=e.responsesReceived,t.availableOutgoingBitrate=e.availableOutgoingBitrate,t.availableIncomingBitrate=e.availableIncomingBitrate}}},t={},function r(n){var s=t[n];if(void 0!==s)return s.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(156);var e,t})}));class RTSLoader{constructor(){this.log=t("rts"),this.stats=new jo.WebRTCStats({getStatsInterval:5e3,getStats:()=>{var e,t;return(null===(t=null===(e=this.engine)||void 0===e?void 0:e.getRTCPeerConnection())||void 0===t?void 0:t.getStats())||Promise.resolve(new Map)}})}stop(){var e,t;null===(e=this.engine)||void 0===e||e.stop(),null===(t=this.stats)||void 0===t||t.stop()}init(e,t,r){r.on("reap",()=>this.stop()),r.on("src",()=>{this.engine&&(this.stop(),r.srcObject=null,this.engine=void 0)}),this.stats.on("stats",e=>{r.emit(Zo.events.STATS,{stats:e}),r.emit("health:record",{event:"rts/stats",detail:{stats:e}})})}onload(e,t,r,n){var s;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(s=this.engine)||void 0===s||s.load(),this.stats.start()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}RTSLoader.pluginName="rts",RTSLoader.events=fo,RTSLoader.state=ho;const Zo=function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}(window,RTSLoader);return Zo}));
|