@flowplayer/player 3.2.6 → 3.2.7-rc.0

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/plugins/health.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.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`${e} -- ${i}`,...o)};return i.log=i,i}const E=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjusted_timestamp:!0}}catch(e){return{timestamp:Date.now(),adjusted_timestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.6",commit:"5a27b6794d5549b093e5031d144faffd489fa309",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function j(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=k(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,E,e,t)}});let g=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(E,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=k(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=B();A(this,k(E,this.eventInfo(e.type))),T(this)}),E.on("visibilitychange",e=>{A(this,k(E,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
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.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",s="fullscreenexit",o="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...s)=>{const o=(null==t?void 0:t.debug)||n;o&&e.match(o)&&console.log(`${e} -- ${i}`,...s)};return i.log=i,i}const E=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),s=await n.json(),o=Date.now()-s.millisUtc-1e3*i;return I.cachedServerOffset=o,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjusted_timestamp:!0}}catch(e){return{timestamp:Date.now(),adjusted_timestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.7-rc.0",commit:"f3c6202420898d27fd0d3042d24c17f35752225b",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const s=k(t,e.eventInfo(n)),{before:o,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(s,C(o),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function j(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=k(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,o,r,a,u,e].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,s].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,E,e,t)}});let g=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(E,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=k(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return A(this,t,!0);const i=n.code,s={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,s),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=B();A(this,k(E,this.eventInfo(e.type))),T(this)}),E.on("visibilitychange",e=>{A(this,k(E,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
package/plugins/ovp.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function D(t,e){let n=0;function o(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:I(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),i(),n=setInterval(i,250)}function I(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+C(e.hours)+":"+C(e.minutes)+":"+C(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const k=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||M(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(V(),e.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!M(i))return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),D(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function I(t,e){let n=0;function o(){const o=M(e);if(o<0||isNaN(o)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var i,r,a;i=t,r=t.root,a=o,r.classList.add("is-livecountdown"),i.emit("ovp:live:countdown:tick",{remaining_time:D(a+1)}),i.hasState("is-starting")||i.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function D(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+C(e.hours)+":"+C(e.minutes)+":"+C(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const k=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof e||M(e)>0)return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(V(),e.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),M(i)<=0)return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
package/plugins/ssai.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.ssai=t())}(this,(function(){"use strict";function e(e,t){const n=document.createElement("div");n.classList.add("ad-ui","ssai");const i=function(e){const t=document.createElement("div");return t.classList.add("skippable-button","disabled"),e.append(t),t}(n),r=function(e){const t=document.createElement("div");return t.classList.add("timeline"),e.append(t),t}(n),s=function(e,t){const n=document.createElement("div");return n.classList.add("resume"),e.append(n),n.addEventListener("click",e=>t.togglePlay(!0)),n}(n,t);return e.append(n),{container:n,timeline:r,resume:s,skippable:i}}const t="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"currentTime");function n(e){var n;if(t)return null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(e)}function i(e,n){var i;if(t)return null===(i=null==t?void 0:t.set)||void 0===i?void 0:i.call(e,n)}const r="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"duration");function s(e){var t;if(r)return null===(t=null==r?void 0:r.get)||void 0===t?void 0:t.call(e)}var a;function o(e,t){var n;const i=null===(n=e.ssai)||void 0===n?void 0:n.state;return i?{ok:t(i)}:{err:a.NotAvailable}}!function(e){e[e.NotAvailable=0]="NotAvailable"}(a||(a={}));var c=Object.freeze({__proto__:null,SSAI_AD_START:"ssai:ad:start",SSAI_AD_END:"ssai:ad:end",SSAI_AD_PROGRESS:"ssai:ad:progress"});function u(e,t){e.setState("ssai-ad-active",!0),e.emit("ssai:ad:start"),o(e,e=>e.adProgress={currentTime:0,duration:t}),p(e)}function d(e,t){e.ssai&&(o(e,e=>e.adProgress=t),function(e,{currentTime:t,duration:n}){if(void 0===n)return;const{timeline:i}=e,r=t/n*100,s=i.style.getPropertyValue("--ssai-percent-complete");i.classList.remove("go"),i.style.setProperty("--ssai-percent-previous",s),i.style.setProperty("--ssai-percent-complete",r.toFixed(3)),i.classList.add("go")}(e.ssai.ui,t),e.emit("ssai:ad:progress",t))}function l(e){if(!e.ssai)return;const{state:t,ui:n}=e.ssai;e.setState("ssai-ad-active",!1),function(e){const{timeline:t}=e;t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>t.style.setProperty(e,"0"))}(n),o(e,e=>delete e.adProgress),e.emit("ssai:ad:end"),p(e),"number"==typeof t.snapbackTime&&(i(e,t.snapbackTime),delete t.snapbackTime)}function p(e){e.videoHeight&&e.videoWidth&&e.setOpts({ratio:e.videoHeight/e.videoWidth})}function f(e){const t=e.ssai.ui,r=new google.ima.dai.api.StreamManager(function(e){const t=document.createElement("video");return Object.defineProperty(t,"currentTime",{get:function(){return n(e)},set:function(t){return i(e,t)}}),Object.defineProperty(t,"duration",{get:function(){return s(e)},set:function(){}}),t.addEventListener=function(t,n){e.addEventListener(t,n)},t}(e),t.container);return r.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,n,i){switch(i.type){case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const n=t.getStreamData();if(e.setOpts({dvr:!1}),n.url)return e.setSrc(n.url);if(n.errorMessage)return e.emit("error",{message:n.errorMessage});return e.emit("error",{message:"dai content was unavailable"})}(e,i);case google.ima.dai.api.StreamEvent.Type.ERROR:return function(e,t,n){if(n)return e.setSrc(n);e.emit("error",{message:"error loading stream"})}(e,0,e.opt("dai.backup"));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return u(e);case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return l(e);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=i.getStreamData();return t.adProgressData&&d(e,t.adProgressData)}case google.ima.dai.api.StreamEvent.Type.CLICK:return function(e,t,n){if(e.paused)return e.play();e.pause()}(e);default:console.warn("[flowplayer.dai] unhandled event=%s\n%o",i.type,i)}}(e,0,0,t)},!1),e.on("ID3",({data:e})=>{e&&Array.isArray(e.cues)&&e.cues.forEach(e=>{const t={},n=e.value;t[n.key]=n.data,r.onTimedMetadata(t)})}),{streamManager:r}}function m(e,t){return"string"==typeof t.assetKey?function(e,t){const n=new google.ima.dai.api.LiveStreamRequest;n.assetKey=t.assetKey||"",n.apiKey=t.apiKey||"",e.requestStream(n)}(e,t):function(e,t){const n=new google.ima.dai.api.VODStreamRequest;n.contentSourceId=t.contentSrcId||"",n.videoId=t.videoId||"",n.apiKey=t.apiKey||"",e.requestStream(n)}(e,t)}var g=Object.freeze({__proto__:null,exists:function(){var e,t;return!!(null===(t=null===(e=window.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.dai)},init:function(e,t){t.ssai&&Object.assign(t.ssai,f(t))},srcIsValid:function(e){return"google/dai"==e.type&&!!(e.videoId||e.contentSrcId||e.assetKey)},onload:function(e,t){var n;(null===(n=e.ssai)||void 0===n?void 0:n.streamManager)&&m(e.ssai.streamManager,t)},getContentCurrentTime:function(e){const t=e.ssai.streamManager,i=n(e);return t?t.contentTimeForStreamTime(i):i},setContentCurrentTime:function(e,t){if(.1==t)return;const n=e.ssai.streamManager;return i(e,n?n.streamTimeForContentTime(t):t)},getContentDuration:function(e){const t=e.ssai.streamManager,n=s(e);return t?t.contentTimeForStreamTime(n):n},getPreviousActiveAdStart:function(e,t){const n=e.ssai.streamManager.previousCuePointForStreamTime(t);if(n&&!n.played)return n.start}});const v=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends v.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=n(this.video);i(this.video,e+t/1e3)}u(this.video,e.getStart())}onAdvertBreakEnd(){l(this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function y(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const i=e.getPayload();if(i.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=i;const e=new EventObserver(t);i.addAnalyticObserver(e),t.setSrc({src:i.getPlaybackUrl()}),setInterval(()=>{const e=1e3*n(t);i.onPlayheadUpdate(e),function(e,t,n){const i=e.getCurrentAdBreak();if(!i)return;const r={currentTime:n-i.getStart(),duration:i.getDuration()};d(t,r)}(i,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+i.getResultCode())})}const S=[g,Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}())},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&y(t.src,e)},getContentCurrentTime:function(e){const t=n(e),i=e.ssai.session;return i?i.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const n=e.ssai.session;return i(e,n?n.getPlayheadForContentPosition(1e3*t)/1e3:t)},getContentDuration:function(e){const t=e.ssai.session,n=s(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:n},getPreviousActiveAdStart:function(e,t){const n=e.ssai.session;if(!n)return;const i=n.getAdBreaks();let r;const s=1e3*t;return i.forEach(e=>{void 0===r&&e.getStart()<s&&e.isActive()&&(r=e)}),void 0!==r?r.getStart()/1e3:void 0}})];class Ssai{init(t,r,a){S.forEach(t=>{!a.ssai&&t.exists()&&(a.ssai={provider:t,ui:e(r,a),state:{snapback:!1}},t.init(r,a),function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return n(e)},set:function(t){if(e.ssai){if(e.ssai.state.adProgress)return;return e.ssai.provider.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return s(e)},set:function(){}})}(a),a.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:r}=e.ssai;if(r.snapback)return r.snapback=!1;const s=n(e),a=t.getPreviousActiveAdStart(e,s);void 0!==a&&(r.snapback=!0,r.snapbackTime=s,i(e,a))}(a)))})}onload(e,t,n,i){var r;(null===(r=n.ssai)||void 0===r?void 0:r.provider)&&n.ssai.provider.onload(n,i)}wants(e,t,n){let i=!1;return S.forEach(e=>{if(!i&&e.exists()&&e.srcIsValid(t))return i=!0}),i}}return Ssai.events=c,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Ssai),Ssai}));
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.ssai=t())}(this,(function(){"use strict";function e(e,t){const n=document.createElement("div");n.classList.add("ad-ui","ssai");const i=function(e){const t=document.createElement("div");return t.classList.add("skippable-button","disabled"),e.append(t),t}(n),r=function(e){const t=document.createElement("div");return t.classList.add("timeline"),e.append(t),t}(n),s=function(e,t){const n=document.createElement("div");return n.classList.add("resume"),e.append(n),n.addEventListener("click",e=>t.togglePlay(!0)),n}(n,t);return e.append(n),{container:n,timeline:r,resume:s,skippable:i}}const t="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"currentTime");function n(e){var n;if(t)return null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(e)}function i(e,n){var i;if(t)return null===(i=null==t?void 0:t.set)||void 0===i?void 0:i.call(e,n)}const r="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"duration");function s(e){var t;if(r)return null===(t=null==r?void 0:r.get)||void 0===t?void 0:t.call(e)}var a;function o(e,t){var n;const i=null===(n=e.ssai)||void 0===n?void 0:n.state;return i?{ok:t(i)}:{err:a.NotAvailable}}!function(e){e[e.NotAvailable=0]="NotAvailable"}(a||(a={}));var c=Object.freeze({__proto__:null,SSAI_AD_START:"ssai:ad:start",SSAI_AD_END:"ssai:ad:end",SSAI_AD_PROGRESS:"ssai:ad:progress"});function u(e,t){e.setState("ssai-ad-active",!0),e.emit("ssai:ad:start"),o(e,e=>e.adProgress={currentTime:0,duration:t}),p(e)}function d(e,t){e.ssai&&(o(e,e=>e.adProgress=t),function(e,{currentTime:t,duration:n}){if(void 0===n)return;const{timeline:i}=e,r=t/n*100,s=i.style.getPropertyValue("--ssai-percent-complete");i.classList.remove("go"),i.style.setProperty("--ssai-percent-previous",s),i.style.setProperty("--ssai-percent-complete",r.toFixed(3)),i.classList.add("go")}(e.ssai.ui,t),e.emit("ssai:ad:progress",t))}function l(e){if(!e.ssai)return;const{state:t,ui:n}=e.ssai;e.setState("ssai-ad-active",!1),function(e){const{timeline:t}=e;t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>t.style.setProperty(e,"0"))}(n),o(e,e=>delete e.adProgress),e.emit("ssai:ad:end"),p(e),"number"==typeof t.snapbackTime&&(i(e,t.snapbackTime),delete t.snapbackTime)}function p(e){e.videoHeight&&e.videoWidth&&e.setOpts({ratio:e.videoHeight/e.videoWidth})}function f(e){const t=e.ssai.ui,r=new google.ima.dai.api.StreamManager(function(e){const t=document.createElement("video");return Object.defineProperty(t,"currentTime",{get:function(){return n(e)},set:function(t){return i(e,t)}}),Object.defineProperty(t,"duration",{get:function(){return s(e)},set:function(){}}),t.addEventListener=function(t,n){e.addEventListener(t,n)},t}(e),t.container);return r.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,n,i){switch(i.type){case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const n=t.getStreamData();if(e.live_state.dvr=!1,n.url)return e.setSrc(n.url);if(n.errorMessage)return e.emit("error",{message:n.errorMessage});return e.emit("error",{message:"dai content was unavailable"})}(e,i);case google.ima.dai.api.StreamEvent.Type.ERROR:return function(e,t,n){if(n)return e.setSrc(n);e.emit("error",{message:"error loading stream"})}(e,0,e.opt("dai.backup"));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return u(e);case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return l(e);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=i.getStreamData();return t.adProgressData&&d(e,t.adProgressData)}case google.ima.dai.api.StreamEvent.Type.CLICK:return function(e,t,n){if(e.paused)return e.play();e.pause()}(e);default:console.warn("[flowplayer.dai] unhandled event=%s\n%o",i.type,i)}}(e,0,0,t)},!1),e.on("ID3",({data:e})=>{e&&Array.isArray(e.cues)&&e.cues.forEach(e=>{const t={},n=e.value;t[n.key]=n.data,r.onTimedMetadata(t)})}),{streamManager:r}}function m(e,t){return"string"==typeof t.assetKey?function(e,t){const n=new google.ima.dai.api.LiveStreamRequest;n.assetKey=t.assetKey||"",n.apiKey=t.apiKey||"",e.requestStream(n)}(e,t):function(e,t){const n=new google.ima.dai.api.VODStreamRequest;n.contentSourceId=t.contentSrcId||"",n.videoId=t.videoId||"",n.apiKey=t.apiKey||"",e.requestStream(n)}(e,t)}var v=Object.freeze({__proto__:null,exists:function(){var e,t;return!!(null===(t=null===(e=window.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.dai)},init:function(e,t){t.ssai&&Object.assign(t.ssai,f(t))},srcIsValid:function(e){return"google/dai"==e.type&&!!(e.videoId||e.contentSrcId||e.assetKey)},onload:function(e,t){var n;(null===(n=e.ssai)||void 0===n?void 0:n.streamManager)&&m(e.ssai.streamManager,t)},getContentCurrentTime:function(e){const t=e.ssai.streamManager,i=n(e);return t?t.contentTimeForStreamTime(i):i},setContentCurrentTime:function(e,t){if(.1==t)return;const n=e.ssai.streamManager;return i(e,n?n.streamTimeForContentTime(t):t)},getContentDuration:function(e){const t=e.ssai.streamManager,n=s(e);return t?t.contentTimeForStreamTime(n):n},getPreviousActiveAdStart:function(e,t){const n=e.ssai.streamManager.previousCuePointForStreamTime(t);if(n&&!n.played)return n.start}});const g=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends g.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=n(this.video);i(this.video,e+t/1e3)}u(this.video,e.getStart())}onAdvertBreakEnd(){l(this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function y(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const i=e.getPayload();if(i.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=i;const e=new EventObserver(t);i.addAnalyticObserver(e),t.setSrc({src:i.getPlaybackUrl()}),setInterval(()=>{const e=1e3*n(t);i.onPlayheadUpdate(e),function(e,t,n){const i=e.getCurrentAdBreak();if(!i)return;const r={currentTime:n-i.getStart(),duration:i.getDuration()};d(t,r)}(i,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+i.getResultCode())})}const S=[v,Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}())},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&y(t.src,e)},getContentCurrentTime:function(e){const t=n(e),i=e.ssai.session;return i?i.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const n=e.ssai.session;return i(e,n?n.getPlayheadForContentPosition(1e3*t)/1e3:t)},getContentDuration:function(e){const t=e.ssai.session,n=s(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:n},getPreviousActiveAdStart:function(e,t){const n=e.ssai.session;if(!n)return;const i=n.getAdBreaks();let r;const s=1e3*t;return i.forEach(e=>{void 0===r&&e.getStart()<s&&e.isActive()&&(r=e)}),void 0!==r?r.getStart()/1e3:void 0}})];class Ssai{init(t,r,a){S.forEach(t=>{!a.ssai&&t.exists()&&(a.ssai={provider:t,ui:e(r,a),state:{snapback:!1}},t.init(r,a),function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return n(e)},set:function(t){if(e.ssai){if(e.ssai.state.adProgress)return;return e.ssai.provider.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return s(e)},set:function(){}})}(a),a.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:r}=e.ssai;if(r.snapback)return r.snapback=!1;const s=n(e),a=t.getPreviousActiveAdStart(e,s);void 0!==a&&(r.snapback=!0,r.snapbackTime=s,i(e,a))}(a)))})}onload(e,t,n,i){var r;(null===(r=n.ssai)||void 0===r?void 0:r.provider)&&n.ssai.provider.onload(n,i)}wants(e,t,n){let i=!1;return S.forEach(e=>{if(!i&&e.exists()&&e.srcIsValid(t))return i=!0}),i}}return Ssai.events=c,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Ssai),Ssai}));