@flowplayer/player 3.0.7 → 3.0.8-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.
@@ -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.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const n=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(n);return"function"!=typeof l?o:l})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function s(t,n,o){0!=o.reaper&&o.floating&&r(o,n,e)}function r(t,n,o){const l=n.clientWidth,s=n.clientHeight;o&&t.emit(o),setTimeout((function(){const r=n.querySelector(".fp-float-wrapper");if(!r)return;const i=getComputedStyle(r),a=o===e?"auto":(r.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight))/l*s+"px";r.style.setProperty("height",a),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const i={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,i)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,i){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll,t.autopause&&i.setOpts({autopause:!1});const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),t.getFullsceenTarget=()=>n,n}(o,i),was_user_toggled:!1};i.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(i,"flowplayer-header");u&&function(e,t,o,l){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(n(l,"flowplayer-close-icon"),{role:"button"}));const i=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,o,l)};r.addEventListener("click",i),e.append(r),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",i)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(l,"flowplayer-mute-icon"),n(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,o,i);const p=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+o}))),s}}(0,(function(){if(l(o)){if(i.hasState("is-fullscreen"))return;s(0,o,i)}})),f=function(){r(i,o)};i.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(i)&&!c.was_user_toggled&&function(e,t,n){0==n.reaper||n.floating||r(n,t,"float:pop:out")}(0,o,i)}),i.on("viewenter",(function(){c.was_user_toggled=!1})),i.on("float:pop:out",(function(){window.addEventListener("scroll",p),i.floating=!0,i.setState("is-popped-out",!0),window.addEventListener("resize",f)})),i.on(e,(function(){window.removeEventListener("scroll",p),i.floating=!1,i.setState("is-popped-out",!1),window.removeEventListener("resize",f)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,FloatOnScroll)}));
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.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const o=(e,t)=>new(((e,t)=>{const o=e.get(t);if(!o)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(o);return"function"!=typeof l?n:l})(e._customElements,t))(e),n=(e,t,o)=>{window.customElements.get(t)||window.customElements.define(t,o),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),o=window.innerHeight,n=t.y;return n>o||n+t.height<0?0:t.y<0?(t.height+n)/t.height:o-t.y>t.height?1:Math.abs((o-t.y)/t.height)}(e)>.8}function s(t,o,n){0!=n.reaper&&n.floating&&r(n,o,e)}function r(t,o,n){n&&t.emit(n),setTimeout((function(){const l=o.querySelector(".fp-float-wrapper"),s=o.querySelector(".fp-ratio");l&&s&&(l.style.height=n===e?"auto":l.clientWidth*parseFloat(s.style.paddingTop)/100+"px",t.emit("resize"))}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const i={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,n(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,i)}}),n(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),n(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,n,i){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll,t.autopause&&i.setOpts({autopause:!1});const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const o=document.createElement("div");return o.classList.add("fp-float-wrapper"),e.appendChild(o),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===o||e.classList.contains("fp-ratio"))||o.appendChild(e)})),t.getFullsceenTarget=()=>o,o}(n,i),was_user_toggled:!1};i.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const o=e._customElements.get(t);return o&&e.root.querySelector(o)||void 0}(i,"flowplayer-header");u&&function(e,t,n,l){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(o(l,"flowplayer-close-icon"),{role:"button"}));const i=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,n,l)};r.addEventListener("click",i),e.append(r),setTimeout(()=>{const e=n.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",i)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([o(l,"flowplayer-mute-icon"),o(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,n,i);const p=function(e,t){const o=e||60,n=Math.ceil(1e3/o);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+n}))),s}}(0,(function(){if(l(n)){if(i.hasState("is-fullscreen"))return;s(0,n,i)}})),f=function(){r(i,n)};i.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(i)&&!c.was_user_toggled&&function(e,t,o){0==o.reaper||o.floating||r(o,t,"float:pop:out")}(0,n,i)}),i.on("viewenter",(function(){c.was_user_toggled=!1})),i.on("float:pop:out",(function(){window.addEventListener("scroll",p),i.floating=!0,i.setState("is-popped-out",!0),window.addEventListener("resize",f)})),i.on(e,(function(){window.removeEventListener("scroll",p),i.floating=!1,i.setState("is-popped-out",!1),window.removeEventListener("resize",f)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const o=e.flowplayer;return"function"==typeof o?(o(t),t):(Array.isArray(o.extensions)||(o.extensions=[]),~o.extensions.indexOf(t)||o.extensions.push(t),t)}(window,FloatOnScroll)}));
package/plugins/health.js CHANGED
@@ -1,4 +1,4 @@
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",f="ended",h="seeked",p="seeking";function v(e){try{return!!new URL(e)}catch(e){return!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 v(e){try{return!!new URL(e)}catch(e){return!1}}
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -13,4 +13,4 @@
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- function m(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}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,D=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var I;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(I||(I={}));const w=e=>{switch(e){case!0:return I.ON;case!1:return I.OFF;default:return e}},N=[];function T(e){const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://health.flowplayer.com/v1/health/events",t))}function A(e,t,n){return m(this,void 0,void 0,(function*(){const i=yield 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=()=>m(void 0,void 0,void 0,(function*(){try{const e=yield function(){return m(this,void 0,void 0,(function*(){const e=D.cachedServerOffset;if(e)return e;const t=D.pendingRequest||(D.pendingRequest=fetch(R)),n=yield t,i=parseInt(n.headers.get("age")||"0"),o=yield n.json(),s=Date.now()-o.millisUtc-1e3*i;return D.cachedServerOffset=s,D.cachedServerOffset}))}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!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.0.7",commit:"178ca8981c70040bed1ea4b7bafff75b5ba10ce1",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:w(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 x(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 j;function F(e){switch(e){case j.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case j.MEDIA_ERR_NETWORK:return"a network error occurred";case j.MEDIA_ERR_DECODE:return"unable to decode media content";case j.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case j.NO_INTERNET:return"no internet connection detected";case j.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"}(j||(j={}));const L=(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.logger=function(e,t){return{log:(...n)=>{const i=e.opt("debug");i&&t.match(i)&&console.log(t,...n)}}}(t,"health"),this.media_session_id=B();const n=setInterval(()=>T(this),2e3);t.on("reap",()=>clearInterval(n));const i=this;if(t.health={get media_session_id(){return i.media_session_id},set media_session_id(e){i.media_session_id=e},get session_id(){return i.session_id},set session_id(e){i.session_id=e}},!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}}init(t,m,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,h,f,i,o].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",L(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",L(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{height:m.clientHeight,width:m.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return x(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||F(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(!v(E.original_src))return;if(!v(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}));
16
+ function m(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}const E=navigator;function y(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 g(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 D;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(D||(D={}));const w=e=>{switch(e){case!0:return D.ON;case!1:return D.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}}`),g("https://health.flowplayer.com/v1/health/events",t))}function A(e,t,n){return m(this,void 0,void 0,(function*(){const i=yield 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=()=>m(void 0,void 0,void 0,(function*(){try{const e=yield function(){return m(this,void 0,void 0,(function*(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=yield t,i=parseInt(n.headers.get("age")||"0"),o=yield n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}))}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!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.0.8-rc.0",commit:"99d3fcc369f69692184449614e9289cc8dce6a8a",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:w(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:y(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 x(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 L=[1e7]+""+-1e3+-4e3+-8e3+-1e11,M=()=>"undefined"==typeof crypto?"":L.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var B;function j(e){switch(e){case B.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case B.MEDIA_ERR_NETWORK:return"a network error occurred";case B.MEDIA_ERR_DECODE:return"unable to decode media content";case B.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case B.NO_INTERNET:return"no internet connection detected";case B.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"}(B||(B={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=M();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=function(e,t){return{log:(...n)=>{const i=e.opt("debug");i&&t.match(i)&&console.log(t,...n)}}}(t,"health"),this.media_session_id=M(),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,m,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:m.clientHeight,width:m.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return x(this,E,e,t)}});let y=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<y)return;y=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(!v(E.original_src))return;if(!v(n))return;if(n==E.original_src)return;this.media_session_id=M();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 +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.subtitles=t())}(this,(function(){"use strict";function e(e,t,n){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;o.length;){if(null==e)return n;const t=o.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,o=t.size;n.setProperty("--caption-size",o.toString());const i=t.position;i&&"auto"!==i&&t?n.setProperty("--caption-position",i.toString()):n.removeProperty("--caption-position");const s="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=s&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(s),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}var n;function o(e,t){if(function(e){return Object.values(n).includes(e)}(t=t||n.Anonymous))return"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function i(e){const t=document.createElement("a");return t.href=e,t.origin}function s(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.id=["fp",t.lang].join("-");const s=n.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),i(e.src)!==i(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(o(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&o(e,t.crossorigin),Object.keys(t).forEach(e=>{n[e]=t[e]}),s.mode=t.default?"showing":t.mode||"disabled",n.onload=function(){},s.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(n||(n={}));function r(e){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),o=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),s=/SamsungBrowser/.test(t),r=s&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:o,iphone:n,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&r,touch:!!("ontouchstart"in window)}})().ios&&(e.on("fullscreenenter",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="hidden"===e.mode?"showing":"disabled"}))})),e.on("fullscreenexit",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="showing"===e.mode?"hidden":"disabled"}))})))}const c=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="flowplayer-subtitles-menu",a="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(d(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${u}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=c(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(u,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const o=document.createElement("span");o.textContent=e.text,n.append(o),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(a,n===e&&(this.localName!==l||!t.classList.contains(a)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(a)})}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function m(e,t,n){const o=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(o),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,l,FlowplayerMenu)}init(n,o,i){const a=c(i,l);a instanceof FlowplayerMenu&&a.setMenuAttrs({class:"fp-cc",summaryTitle:i.i18n("cc.button","CC"),menuTitle:i.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(i);let d,p=[],h=[];function y(e){var t;if(e==d)return v();v(),null===(t=i.root.querySelector(l))||void 0===t||t.summaryEle.classList.add("fp-color-text"),e.mode="hidden",d=e,i.emit("cuechange",{track:e}),i.emit("tracks:text:updated",d)}function v(){var e;d&&(i.emit("tracks:text:updated"),null===(e=i.root.querySelector(l))||void 0===e||e.summaryEle.classList.remove("fp-color-text"),d.mode="disabled",d=void 0,t(u,[]))}i.on("mount",(function(){var e;const t=f(i,"flowplayer-control");if(!t)return null===(e=f(i,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);t.insertAdjacentElement("beforebegin",u),t.append(a),a instanceof FlowplayerMenu&&a.menuContainer.addEventListener("click",()=>{var e;1===h.length&&(null===(e=a.querySelector("li"))||void 0===e||e.click())})})),i.on("config",(function(e){var t,n;const o=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;o&&p!==o&&(p=o,0===p.length&&(m(a,Subtitles.events.TRACKS,[]),v(),h=[]),Array.from(i.querySelectorAll(".fp-track")).forEach(e=>{i.removeChild(e)}),p.forEach(e=>s(i,e)))})),i.textTracks.addEventListener("addtrack",()=>{const t=Array.from(i.textTracks).filter((function(e){return~["captions","subtitles","descriptions"].indexOf(e.kind)}));if(h.length===t.length&&h.every((e,n)=>e===t[n]))return;let o;t.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(o=e,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){i.emit(e.type,{track:e.target})},e})),m(a,Subtitles.events.TRACKS,t.map((function(e){return{text:e.label,onclick:y.bind(0,e)}}))),h=t.slice();const s=e(n,"subtitles.show");if(o=(!1!==s?o:void 0)||h.find(e=>e.label===(null==d?void 0:d.label)),!o)return v();y(o),m(a,Subtitles.events.SWITCH,{selected_index:h.indexOf(o)})}),i.on("cuechange",(function(n){var o;const i=null===(o=n.data)||void 0===o?void 0:o.track,s=Array.from(e(i,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,s)})),r(i)}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change"},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,Subtitles),Subtitles}));
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.subtitles=t())}(this,(function(){"use strict";function e(e,t,n){const i=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;i.length;){if(null==e)return n;const t=i.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,i=t.size;n.setProperty("--caption-size",i.toString());const o=t.position;o&&"auto"!==o&&t?n.setProperty("--caption-position",o.toString()):n.removeProperty("--caption-position");const s="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=s&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(s),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}var n;function i(e,t){if(function(e){return Object.values(n).includes(e)}(t=t||n.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function o(e){const t=document.createElement("a");return t.href=e,t.origin}function s(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.id=["fp",t.lang].join("-");const s=n.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),o(e.src)!==o(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(i(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&i(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(n[e]=t[e])}),s.mode=t.default?"hidden":"disabled",n.onload=function(){},s.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(n||(n={}));function r(e){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),i=/Android/.test(t)&&!/Firefox/.test(t),o=/^((?!chrome|android).)*safari/i.test(t),s=/SamsungBrowser/.test(t),r=s&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:n,safari:o,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&r,touch:!!("ontouchstart"in window)}})().ios&&(e.on("fullscreenenter",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="hidden"===e.mode?"showing":"disabled"}))})),e.on("fullscreenexit",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="showing"===e.mode?"hidden":"disabled"}))})))}const c=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?i:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="flowplayer-subtitles-menu",a="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(d(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${u}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=c(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(u,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const i=document.createElement("span");i.textContent=e.text,n.append(i),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(a,n===e&&(this.localName!==l||!t.classList.contains(a)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(a)})}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function m(e,t,n){const i=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(i),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,l,FlowplayerMenu)}init(n,i,o){const a=c(o,l);a instanceof FlowplayerMenu&&a.setMenuAttrs({class:"fp-cc",summaryTitle:o.i18n("cc.button","CC"),menuTitle:o.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(o);let d,p=[],h=[];function y(e){var t;if(e==d)return g();g(),null===(t=o.root.querySelector(l))||void 0===t||t.summaryEle.classList.add("fp-color-text"),e.mode="hidden",d=e,o.emit("cuechange",{track:e}),o.emit("tracks:text:updated",d)}function g(){var e;d&&(o.emit("tracks:text:updated"),null===(e=o.root.querySelector(l))||void 0===e||e.summaryEle.classList.remove("fp-color-text"),d.mode="disabled",d=void 0,t(u,[]))}o.on("mount",(function(){var e;const t=f(o,"flowplayer-control");if(!t)return null===(e=f(o,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);t.insertAdjacentElement("beforebegin",u),t.append(a),a instanceof FlowplayerMenu&&a.menuContainer.addEventListener("click",()=>{var e;1===h.length&&(null===(e=a.querySelector("li"))||void 0===e||e.click())})})),o.on("config",(function(e){var t,n;const i=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;i&&p!==i&&(p=i,0===p.length&&(m(a,Subtitles.events.TRACKS,[]),g(),h=[]),Array.from(o.querySelectorAll(".fp-track")).forEach(e=>{["captions","subtitles","descriptions"].includes(e.kind)&&o.removeChild(e)}),p.forEach(e=>s(o,e)))})),o.textTracks.addEventListener("addtrack",()=>{const t=Array.from(o.textTracks).filter((function(e){return~["captions","subtitles","descriptions"].indexOf(e.kind)}));if(h.length===t.length&&h.every((e,n)=>e===t[n]))return;let i;t.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(i=e,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){o.emit(e.type,{track:e.target})},e})),m(a,Subtitles.events.TRACKS,t.map((function(e){return{text:e.label,onclick:y.bind(0,e)}}))),h=t.slice();const s=e(n,"subtitles.show");if(i=(!1!==s?i:void 0)||h.find(e=>e.label===(null==d?void 0:d.label)),!i)return g();y(i),m(a,Subtitles.events.SWITCH,{selected_index:h.indexOf(i)})}),o.on("cuechange",(function(n){var i;const o=null===(i=n.data)||void 0===i?void 0:i.track;if(!o||!["captions","subtitles","descriptions"].includes(o.kind))return;const s=Array.from(e(o,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,s)})),r(o)}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change"},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,Subtitles),Subtitles}));
@@ -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.thumbnails=t())}(this,(function(){"use strict";var e;function t(t,n){if(function(t){return Object.values(e).includes(t)}(n=n||e.Anonymous))return"crossOrigin"in t?t.crossOrigin=n:t.setAttribute("crossorigin",n),t}function n(e){const t=document.createElement("a");return t.href=e,t.origin}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(e||(e={}));function r(e,t){return e.querySelector("track[id='"+t+"']")}function o(e,r){const o=document.createElement("track");return o.src=r,function(e,t){try{return e.src.startsWith("blob:"),n(e.src)!==n(t)}catch(e){return console.error(e),!0}}(e,r)&&(e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),t(e),t(o)),o}function s(e,t){if(function(e,t){return e.querySelector("track[src='"+t+"']")}(e,t))return;!function(e){const t=r(e,"thumbnails");t&&t.remove()}(e);const n=o(e,t);return n.kind="metadata",n.id="thumbnails",n.src=t,e.append(n),n}var i=Object.freeze({__proto__:null,THUMBNAILS_RENDER:"thumbnails:render",THUMBNAILS_HIDE:"thumbnails:hide"});class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}function u(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerThumbnails extends FlowplayerComponent{constructor(e){super(e),this.className="fp-thumbnail-carousel",this.carousel=this.makeCarousel(),e.on("thumbnails:render",this.onRender.bind(this,e)),e.on("thumbnails:hide",()=>e.root.classList.remove("with-thumbnails"))}onRender(e,t){var n;if(!e.reaper)return;const r=null===(n=t.detail)||void 0===n?void 0:n.timestamp;if("number"!=typeof r)return;const o=Thumbnails.activeThumbnails(e,r);o&&this.renderCarousel(e,o)}renderCarousel(e,{previous:t,current:n,next:r}){e.root.classList.add("with-thumbnails"),t&&this.renderCarouselItem(this.carousel.previous,t),n&&this.renderCarouselItem(this.carousel.current,n),r&&this.renderCarouselItem(this.carousel.next,r)}makeCarousel(){return{previous:this.makeCarouselItem("previous"),current:this.makeCarouselItem("current"),next:this.makeCarouselItem("next")}}makeCarouselItem(e){const t=document.createElement("div");return t.classList.add("thumbnail",e),this.append(t),t}renderCarouselItem(e,t){const n=e.style;n.backgroundImage=`url("${t.url}")`,n.backgroundPositionX="-"+t.x+"px ",n.backgroundPositionY="-"+t.y+"px",n.height=t.h+"px",n.width=t.w+"px"}}function l(e){const t=document.createElement("a");return t.href=e,t}const c=/#xywh=(\d+),(\d+),(\d+),(\d+)$/,m=/^(https:|https:|\/)/;function d(e,t){const n=l(e.src),r=l(t),[o,s,i,u,a]=(r.hash.match(c)||[]).map(e=>parseInt(e,10));return{x:s,y:i,w:u,h:a,url:h(t,n)}}function h(e,t){if(e.match(m))return e;try{return new URL(e,t.href).toString()}catch(e){return""}}class Thumbnails{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-thumbnails-carousel",FlowplayerThumbnails)}static activeThumbnails(e,t){var n,o;const s=r(e,"thumbnails");if(!s)return;const i=Array.from(s.track.cues||{length:0}),u=i.find(e=>e.startTime<=t&&t<=e.endTime);if(!u)return{};const a=i.indexOf(u);return{previous:d(s,(null===(n=i[a-1])||void 0===n?void 0:n.text)||""),current:d(s,(null==u?void 0:u.text)||""),next:d(s,(null===(o=i[a+1])||void 0===o?void 0:o.text)||"")}}init(e,t,n){const r=u(n,"flowplayer-ui"),o=u(n,"flowplayer-control");n.reaper&&r&&o&&(r.insertBefore(a(n,"flowplayer-thumbnails-carousel"),o),n.once("mount",(function(){var e;u(e=n,"flowplayer-timeline-bar")&&(e.on("timeline/gesture/move",({data:t})=>{const n=null==t?void 0:t.percent;if("number"!=typeof n)return;if(!Number.isFinite(e.duration))return;const r=Pipe.of(e.duration*(n/100)).fmap(Math.min,e.duration).fmap(Math.max,0).unwrap();requestAnimationFrame(()=>{e.emit("thumbnails:render",{timestamp:r})})}),e.on("timeline/gesture/end",()=>{e.emit("thumbnails:hide")}))})),n.textTracks.addEventListener("addtrack",(function(e){const t=e.track;"thumbnails"===(null==t?void 0:t.id)&&(t.mode="hidden")})),n.on("config",(function(){var t;const r=null===(t=null==e?void 0:e.thumbnails)||void 0===t?void 0:t.src;if("string"==typeof r)return s(n,r)})))}}return Thumbnails.events=i,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,Thumbnails),Thumbnails}));
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.thumbnails=t())}(this,(function(){"use strict";var e;function t(t,n){if(function(t){return Object.values(e).includes(t)}(n=n||e.Anonymous))return t instanceof HTMLVideoElement&&(t.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in t?t.crossOrigin=n:t.setAttribute("crossorigin",n),t}function n(e){const t=document.createElement("a");return t.href=e,t.origin}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(e||(e={}));function r(e,t){return e.querySelector("track[id='"+t+"']")}function o(e,r){const o=document.createElement("track");return o.src=r,function(e,t){try{return e.src.startsWith("blob:"),n(e.src)!==n(t)}catch(e){return console.error(e),!0}}(e,r)&&(t(e),t(o)),o}function s(e,t){if(function(e,t){return e.querySelector("track[src='"+t+"']")}(e,t))return;!function(e){const t=r(e,"thumbnails");t&&t.remove()}(e);const n=o(e,t);return n.kind="metadata",n.id="thumbnails",n.src=t,e.append(n),n}var i=Object.freeze({__proto__:null,THUMBNAILS_RENDER:"thumbnails:render",THUMBNAILS_HIDE:"thumbnails:hide"});class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}function u(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerThumbnails extends FlowplayerComponent{constructor(e){super(e),this.className="fp-thumbnail-carousel",this.carousel=this.makeCarousel(),e.on("thumbnails:render",this.onRender.bind(this,e)),e.on("thumbnails:hide",()=>e.root.classList.remove("with-thumbnails"))}onRender(e,t){var n;if(!e.reaper)return;const r=null===(n=t.detail)||void 0===n?void 0:n.timestamp;if("number"!=typeof r)return;const o=Thumbnails.activeThumbnails(e,r);o&&this.renderCarousel(e,o)}renderCarousel(e,{previous:t,current:n,next:r}){e.root.classList.add("with-thumbnails"),t&&this.renderCarouselItem(this.carousel.previous,t),n&&this.renderCarouselItem(this.carousel.current,n),r&&this.renderCarouselItem(this.carousel.next,r)}makeCarousel(){return{previous:this.makeCarouselItem("previous"),current:this.makeCarouselItem("current"),next:this.makeCarouselItem("next")}}makeCarouselItem(e){const t=document.createElement("div");return t.classList.add("thumbnail",e),this.append(t),t}renderCarouselItem(e,t){const n=e.style;n.backgroundImage=`url("${t.url}")`,n.backgroundPositionX="-"+t.x+"px ",n.backgroundPositionY="-"+t.y+"px",n.height=t.h+"px",n.width=t.w+"px"}}function l(e){const t=document.createElement("a");return t.href=e,t}const c=/#xywh=(\d+),(\d+),(\d+),(\d+)$/,m=/^(https:|https:|\/)/;function d(e,t){const n=l(e.src),r=l(t),[o,s,i,u,a]=(r.hash.match(c)||[]).map(e=>parseInt(e,10));return{x:s,y:i,w:u,h:a,url:h(t,n)}}function h(e,t){if(e.match(m))return e;try{return new URL(e,t.href).toString()}catch(e){return""}}class Thumbnails{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-thumbnails-carousel",FlowplayerThumbnails)}static activeThumbnails(e,t){var n,o;const s=r(e,"thumbnails");if(!s)return;const i=Array.from(s.track.cues||{length:0}),u=i.find(e=>e.startTime<=t&&t<=e.endTime);if(!u)return{};const a=i.indexOf(u);return{previous:d(s,(null===(n=i[a-1])||void 0===n?void 0:n.text)||""),current:d(s,(null==u?void 0:u.text)||""),next:d(s,(null===(o=i[a+1])||void 0===o?void 0:o.text)||"")}}init(e,t,n){const r=u(n,"flowplayer-ui"),o=u(n,"flowplayer-control");n.reaper&&r&&o&&(r.insertBefore(a(n,"flowplayer-thumbnails-carousel"),o),n.once("mount",(function(){var e;u(e=n,"flowplayer-timeline-bar")&&(e.on("timeline/gesture/move",({data:t})=>{const n=null==t?void 0:t.percent;if("number"!=typeof n)return;if(!Number.isFinite(e.duration))return;const r=Pipe.of(e.duration*(n/100)).fmap(Math.min,e.duration).fmap(Math.max,0).unwrap();requestAnimationFrame(()=>{e.emit("thumbnails:render",{timestamp:r})})}),e.on("timeline/gesture/end",()=>{e.emit("thumbnails:hide")}))})),n.textTracks.addEventListener("addtrack",(function(e){const t=e.track;"thumbnails"===(null==t?void 0:t.id)&&(t.mode="hidden")})),n.on("config",(function(){var t;const r=null===(t=null==e?void 0:e.thumbnails)||void 0===t?void 0:t.src;if("string"==typeof r)return s(n,r)})))}}return Thumbnails.events=i,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,Thumbnails),Thumbnails}));