@flowplayer/player 3.13.1-rc.0 → 3.14.0-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/core/events.d.ts +21 -3
  2. package/core/events.js +57 -2
  3. package/core.js +1 -1
  4. package/default.js +1 -1
  5. package/embed.js +2 -2
  6. package/flowplayer.css +1 -1
  7. package/index.d.ts +6 -3
  8. package/package.json +13 -2
  9. package/plugins/ads.d.ts +6 -3
  10. package/plugins/ads.js +2 -2
  11. package/plugins/airplay.d.ts +31 -4
  12. package/plugins/airplay.js +1 -1
  13. package/plugins/analytics.d.ts +6 -3
  14. package/plugins/analytics.js +1 -1
  15. package/plugins/asel.d.ts +7 -4
  16. package/plugins/audio.d.ts +6 -3
  17. package/plugins/chapters.d.ts +11 -6
  18. package/plugins/chromecast.d.ts +6 -3
  19. package/plugins/comscore.d.ts +6 -3
  20. package/plugins/consent.d.ts +6 -3
  21. package/plugins/context-menu.d.ts +6 -3
  22. package/plugins/cuepoints.d.ts +12 -3
  23. package/plugins/dash.d.ts +6 -3
  24. package/plugins/drm.d.ts +6 -3
  25. package/plugins/endscreen.d.ts +24 -4
  26. package/plugins/fas.d.ts +6 -3
  27. package/plugins/float-on-scroll.d.ts +9 -3
  28. package/plugins/ga4.d.ts +6 -3
  29. package/plugins/gemius.d.ts +9 -3
  30. package/plugins/google-analytics.d.ts +6 -3
  31. package/plugins/health.d.ts +12 -3
  32. package/plugins/health.js +1 -1
  33. package/plugins/hls.d.ts +11 -5
  34. package/plugins/id3.d.ts +6 -3
  35. package/plugins/iframe.d.ts +7 -3
  36. package/plugins/keyboard.d.ts +6 -3
  37. package/plugins/media-session.d.ts +6 -3
  38. package/plugins/message.d.ts +6 -3
  39. package/plugins/ovp.d.ts +59 -5
  40. package/plugins/ovp.js +1 -1
  41. package/plugins/playlist.d.ts +6 -3
  42. package/plugins/preview.d.ts +6 -3
  43. package/plugins/qsel.d.ts +6 -3
  44. package/plugins/qul.d.ts +6 -3
  45. package/plugins/rts.d.ts +6 -3
  46. package/plugins/share.d.ts +6 -3
  47. package/plugins/speed.d.ts +6 -3
  48. package/plugins/ssai.d.ts +8 -5
  49. package/plugins/ssai.js +1 -1
  50. package/plugins/subtitles.d.ts +157 -8
  51. package/plugins/subtitles.js +1 -1
  52. package/plugins/thumbnails.d.ts +6 -3
  53. package/plugins/tizen.d.ts +6 -3
  54. package/plugins/vtsel.d.ts +6 -3
  55. package/plugins/webos.d.ts +6 -3
  56. package/util/loader.d.ts +6 -3
  57. package/util/loader.js +1 -0
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -155,6 +158,9 @@ export declare type GemiusConfig = Config & {
155
158
  ima?: any;
156
159
  };
157
160
 
161
+ /**
162
+ * @public
163
+ */
158
164
  export declare type GemiusObject = {
159
165
  playerID: string;
160
166
  gemiusID: string;
@@ -247,11 +253,11 @@ declare type PlayerState = string;
247
253
 
248
254
  declare type PlayerWith<T> = T & Player;
249
255
 
250
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
256
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
251
257
  /**
252
258
  * a plugin must always implement the init method so a player instance knows how to initialize it
253
259
  */
254
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
260
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
255
261
  }
256
262
 
257
263
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -172,12 +175,16 @@ declare class Health implements Plugin_2 {
172
175
  init(_config: Config, root: PlayerRoot, player: Player): void;
173
176
  }
174
177
 
178
+ /**
179
+ * @public
180
+ */
175
181
  export declare type HealthClass = Health;
176
182
 
177
183
  declare namespace HealthEvents {
178
184
  export {
179
185
  RECORD,
180
186
  REBUFFER,
187
+ REBUFFER_ENDED,
181
188
  DISPLAY
182
189
  }
183
190
  }
@@ -273,11 +280,11 @@ declare type PlayerWithHealthAPI = Player & {
273
280
  };
274
281
  };
275
282
 
276
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
283
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
277
284
  /**
278
285
  * a plugin must always implement the init method so a player instance knows how to initialize it
279
286
  */
280
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
287
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
281
288
  }
282
289
 
283
290
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -292,6 +299,8 @@ declare enum QualityOpts {
292
299
 
293
300
  declare const REBUFFER = "rebuffer";
294
301
 
302
+ declare const REBUFFER_ENDED = "rebuffer:ended";
303
+
295
304
  declare const RECORD = "health:record";
296
305
 
297
306
  declare type SourceObj = {
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,DISPLAY:"display"});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 y(e){try{return!!new URL(e)}catch(e){return!1}}function E(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{try{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`flowplayer/${e} -- ${i}`,...o)}catch(e){console.warn(e)}};return i.log=i,i}const v=navigator;function m(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=v.connection)||void 0===n?void 0:n.downlink)||-1}function g(e,t){return async function(e,t){try{await fetch(e,{body:t,method:"POST",mode:"no-cors"})}catch(e){}}(e,JSON.stringify({events:t}))}var R;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(R||(R={}));const I=e=>{switch(e){case!0:return R.ON;case!1:return R.OFF;default:return e}};function O(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}const w=[],D="https://ihi.flowplayer.com/v1/health/events";function N(e){if(e.suspended)return;const t=w.slice(0);w.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g(function(){try{return"undefined"==typeof window?D:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:D}catch(e){return D}}(),t))}async function A(e,t,n){const i=await b();w.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),w.length<10&&!n||N(e)}const T=()=>{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}},b=async()=>({client_time:Date.now()}),S=(e,t)=>Object.assign(e,{detail:t}),L=(e,{event:t,media_session_id:n,session_id:i,play_range_id:o})=>({event:t,media_session_id:n,session_id:i,play_range_id:o,device_id:e.deviceId(),version:"3.13.1-rc.0",commit:"83e6f2217915df591bca6548234a0aedf8d214bf",ima_sdk_version:T(),preload:e.opt("preload"),autoplay:I(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:m(e),page_url:O(),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")}),U=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 C(e,t,n,i){const o=L(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,U(s),U(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,k=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function F(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 B=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},P=k();class Health{constructor(e,t){this.session_id=P,this.suspended=!1,this.logger=E("health",t.opts),this.media_session_id=k(),this.play_range_id=k(),this.analyticsLoop=setInterval(()=>N(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop)),t.on(l,()=>{this.play_range_id=k()});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,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>N(this),2e3)}init(t,E,v){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(v),v.on("display",e=>{A(this,L(v,this.eventInfo(e.type)),!0)}),v.on("health:record",({detail:e})=>{const t=L(v,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{v.on(e,e=>{A(this,L(v,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{v.on(e,e=>{A(this,L(v,this.eventInfo(e.type)))})}),v.on("volumechange",B(800,e=>{const t=L(v,this.eventInfo(e.type));A(this,S(t,{volume:parseFloat(v.volume.toFixed(2)),muted:v.muted}))})),v.on("resize",B(800,e=>{const t=L(v,this.eventInfo(e.type));A(this,S(t,{height:E.clientHeight,width:E.clientWidth}))})),v.on("hls/failover",e=>{const t=L(v,this.eventInfo(e.type)),n=e.detail,{reason:i,from:o}=n;A(this,S(t,{reason:i,from:o}))}),v.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return C(this,v,e,t)}});let m=Date.now()-1e3;v.on("timeupdate",e=>{if(Date.now()<m)return;m=Date.now()+5e3;const t=L(v,this.eventInfo(e.type));var n;A(this,S(t,{duration:(n=v.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),v.addEventListener("error",e=>{const t=L(v,this.eventInfo(e.type)),n=e.error||v.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,S(t,o),!0)}),v.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!y(v.original_src))return;if(!y(n))return;if(n==v.original_src)return;this.media_session_id=k();A(this,L(v,this.eventInfo(e.type))),N(this)}),v.on("visibilitychange",e=>{A(this,L(v,this.eventInfo(e.type))),N(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const 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,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,REBUFFER_ENDED:"rebuffer:ended",DISPLAY:"display"});const n="load",i="fullscreenenter",o="fullscreenexit",r="loadedmetadata",s="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",f="ended",h="seeked",p="seeking";function y(e){try{return!!new URL(e)}catch(e){return!1}}function E(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{try{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`flowplayer/${e} -- ${i}`,...o)}catch(e){console.warn(e)}};return i.log=i,i}const v=navigator;function m(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=v.connection)||void 0===n?void 0:n.downlink)||-1}function g(e,t){return async function(e,t){try{await fetch(e,{body:t,method:"POST",mode:"no-cors"})}catch(e){}}(e,JSON.stringify({events:t}))}var R;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(R||(R={}));const I=e=>{switch(e){case!0:return R.ON;case!1:return R.OFF;default:return e}};function O(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}const w=[],D="https://ihi.flowplayer.com/v1/health/events";function N(e){if(e.suspended)return;const t=w.slice(0);w.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g(function(){try{return"undefined"==typeof window?D:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:D}catch(e){return D}}(),t))}async function A(e,t,n){const i=await b();w.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),w.length<10&&!n||N(e)}const T=()=>{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}},b=async()=>({client_time:Date.now()}),S=(e,t)=>Object.assign(e,{detail:t}),L=(e,{event:t,media_session_id:n,session_id:i,play_range_id:o})=>({event:t,media_session_id:n,session_id:i,play_range_id:o,device_id:e.deviceId(),version:"3.14.0-rc",commit:"f515a76bc4f29b25d1c2b299c80cef8cb5cc2f33",ima_sdk_version:T(),preload:e.opt("preload"),autoplay:I(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:m(e),page_url:O(),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")}),U=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 C(e,t,n,i){const o=L(t,e.eventInfo(n)),{before:r,after:s}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,U(r),U(s)))}const F=[1e7]+""+-1e3+-4e3+-8e3+-1e11,M=()=>"undefined"==typeof crypto?"":F.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var k;function x(e){switch(e){case k.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case k.MEDIA_ERR_NETWORK:return"a network error occurred";case k.MEDIA_ERR_DECODE:return"unable to decode media content";case k.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case k.NO_INTERNET:return"no internet connection detected";case k.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"}(k||(k={}));const B=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},P=M();class Health{constructor(e,t){this.session_id=P,this.suspended=!1,this.logger=E("health",t.opts),this.media_session_id=M(),this.play_range_id=M(),this.analyticsLoop=setInterval(()=>N(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop)),t.on(l,()=>{this.play_range_id=M()});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,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>N(this),2e3)}init(t,E,v){!function(t){t.on(u,(function(n){if(t.seeking)return;if(t.networkState!==t.NETWORK_LOADING)return;if(t.readyState===t.HAVE_NOTHING)return;const i=Date.now(),o=e=>{t.off(_,o),t.off("src",o),t.off("error",o),e.type===_&&t.emit("rebuffer:ended",{rebuffer_duration:(Date.now()-i)/1e3})};t.on([_,"error","src"],o),t.emit(e)}))}(v),v.on("display",e=>{A(this,L(v,this.eventInfo(e.type)),!0)}),v.on("health:record",({detail:e})=>{const t=L(v,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,r,s,a,u,e].forEach(e=>{v.on(e,e=>{A(this,L(v,this.eventInfo(e.type)))})}),v.on("rebuffer:ended",e=>{const t=L(v,this.eventInfo(e.type));A(this,Object.assign(t,e.detail))}),[l,c,p,h,f,i,o].forEach(e=>{v.on(e,e=>{A(this,L(v,this.eventInfo(e.type)))})}),v.on("volumechange",B(800,e=>{const t=L(v,this.eventInfo(e.type));A(this,S(t,{volume:parseFloat(v.volume.toFixed(2)),muted:v.muted}))})),v.on("resize",B(800,e=>{const t=L(v,this.eventInfo(e.type));A(this,S(t,{height:E.clientHeight,width:E.clientWidth}))})),v.on("hls/failover",e=>{const t=L(v,this.eventInfo(e.type)),n=e.detail,{reason:i,from:o}=n;A(this,S(t,{reason:i,from:o}))}),v.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return C(this,v,e,t)}});let m=Date.now()-1e3;v.on("timeupdate",e=>{if(Date.now()<m)return;m=Date.now()+5e3;const t=L(v,this.eventInfo(e.type));var n;A(this,S(t,{duration:(n=v.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),v.addEventListener("error",e=>{const t=L(v,this.eventInfo(e.type)),n=e.error||v.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||x(i),error_code:i,error_stack:n.stack||""};return A(this,S(t,o),!0)}),v.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!y(v.original_src))return;if(!y(n))return;if(n==v.original_src)return;this.media_session_id=M();A(this,L(v,this.eventInfo(e.type))),N(this)}),v.on("visibilitychange",e=>{A(this,L(v,this.eventInfo(e.type))),N(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const 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,Health)}));
package/plugins/hls.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import Hls from 'hls.js';
2
- import { HlsConfig } from 'hls.js';
2
+ import type { HlsConfig } from 'hls.js';
3
3
  import type { MediaKeyFunc } from 'hls.js';
4
4
 
5
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
5
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
6
+ infer Current,
7
+ ...infer Remaining
8
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
6
9
 
7
10
  declare const ATTACHED = "hls:attached";
8
11
 
@@ -183,12 +186,15 @@ export declare type HLSConfig = {
183
186
  /**
184
187
  * Force use of native browser HLS implementations if available.
185
188
  * Forcing native HLS will disable manual quality selection and custom hls.js API settings.
186
- * @default false
189
+ * @defaultValue false
187
190
  */
188
191
  native?: boolean;
189
192
  };
190
193
  };
191
194
 
195
+ /**
196
+ * @public
197
+ */
192
198
  export declare type HLSEvents = typeof events;
193
199
 
194
200
  /**
@@ -277,11 +283,11 @@ declare type PlayerState = string;
277
283
 
278
284
  declare type PlayerWith<T> = T & Player;
279
285
 
280
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
286
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
281
287
  /**
282
288
  * a plugin must always implement the init method so a player instance knows how to initialize it
283
289
  */
284
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
290
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
285
291
  }
286
292
 
287
293
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
package/plugins/id3.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -145,6 +148,7 @@ declare interface FPEvent<T> extends CustomEvent<T> {
145
148
  }
146
149
 
147
150
  /**
151
+ * @public
148
152
  * maybe handles iframe specific stuff if inside an iframe
149
153
  */
150
154
  declare const IframePlugin: PluginCtor<KeyValue, KeyValue>;
@@ -228,11 +232,11 @@ declare type PlayerState = string;
228
232
 
229
233
  declare type PlayerWith<T> = T & Player;
230
234
 
231
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
235
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
232
236
  /**
233
237
  * a plugin must always implement the init method so a player instance knows how to initialize it
234
238
  */
235
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
239
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
236
240
  }
237
241
 
238
242
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
package/plugins/ovp.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -100,6 +103,23 @@ declare type DRMVendorImplementation = {
100
103
  }, cb: (license_data: Uint8Array) => void) => void;
101
104
  };
102
105
 
106
+ declare type EndscreenEvents = typeof events;
107
+
108
+ /**
109
+ * @public
110
+ */
111
+ declare type EndscreenRecommendations = {
112
+ playlist: Array<PlaylistItem>;
113
+ };
114
+
115
+ declare namespace events {
116
+ export {
117
+ RECOMMENDATIONS_RENDER,
118
+ RECOMMENDATIONS_HIDE,
119
+ RECOMMENDATIONS_READY
120
+ }
121
+ }
122
+
103
123
  declare type FlowplayerCustomElementRegistry = Map<string, string>;
104
124
 
105
125
  declare interface FlowplayerUMD extends FlowplayerUMDBase {
@@ -167,15 +187,27 @@ declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToC
167
187
  declare type MergePlayerAPIExtensions<Arr extends PluginCtor[]> = ArrayToIntersection<MapToPlayerApiExtensions<Arr>>;
168
188
 
169
189
  /**
170
- * ovp plugin
190
+ * @public
191
+ * OVP plugin
171
192
  */
172
- declare const OVP: PluginCtor<OVPConfig, KeyValue>;
193
+ declare const OVP: PluginCtor<OVPConfig, OVPPlayerAPI>;
173
194
  export default OVP;
174
195
 
196
+ /**
197
+ * @public
198
+ * OVPConfig for npm users to configure the plugin
199
+ */
175
200
  export declare type OVPConfig = {
176
201
  recommendations?: boolean;
177
202
  };
178
203
 
204
+ /**
205
+ * @public
206
+ */
207
+ export declare type OVPPlayerAPI = {
208
+ on(event: EndscreenEvents["RECOMMENDATIONS_READY"], handler: (e: RecommendationsReadyEvent) => void): Player;
209
+ };
210
+
179
211
  declare interface Player extends HTMLVideoElement {
180
212
  renderPlugin: (pluginContainer: HTMLElement) => void;
181
213
  toggleDisable: (flag: boolean) => void;
@@ -232,11 +264,18 @@ declare type PlayerState = string;
232
264
 
233
265
  declare type PlayerWith<T> = T & Player;
234
266
 
235
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
267
+ declare type PlaylistItem = {
268
+ poster?: string;
269
+ title?: string;
270
+ description?: string;
271
+ src: string[];
272
+ };
273
+
274
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
236
275
  /**
237
276
  * a plugin must always implement the init method so a player instance knows how to initialize it
238
277
  */
239
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
278
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
240
279
  }
241
280
 
242
281
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -249,6 +288,21 @@ declare enum QualityOpts {
249
288
  HIGH = 4
250
289
  }
251
290
 
291
+ declare const RECOMMENDATIONS_HIDE = "recommendations:hide";
292
+
293
+ /**
294
+ * @public
295
+ * emitted when recommandations list is available
296
+ **/
297
+ declare const RECOMMENDATIONS_READY = "recommendationsready";
298
+
299
+ declare const RECOMMENDATIONS_RENDER = "recommendations:render";
300
+
301
+ /**
302
+ * @public
303
+ */
304
+ declare type RecommendationsReadyEvent = FPEvent<EndscreenRecommendations>;
305
+
252
306
  declare type SourceObj = {
253
307
  src?: SourceStr;
254
308
  type?: string;
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";function t(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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(r=>{if(e(t[r])&&e(o[r]))return t[r]=n(t[r],o[r]);t[r]=o[r]}),t):t,{});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 o="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),r=window,i=r._flowplayerTimekeeper||(r._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),c()+"/web/public/native/config"+t}const c=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(o)),n=await e,r=parseInt(n.headers.get("age")||"0"),s=await n.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function d(t){return~t.indexOf("/")?t:"/media/"+t}var u={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function p(t,e){var o,r;e="object"==typeof e?e:{};const i={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:r,ad_keywords:i}){return{ad_keywords:i||"",media_id:t||"",category:r||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},a=e.embed||{};return delete a.src,n(s,i,t,(delete(c=e).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),a);var c}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,v=/^[A-Za-z0-9]{8}$/,y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[A-Za-z0-9]{8}$/;function h(t){return"object"==typeof t&&"ovp/base64"==t.type}function w(t,e){return function(t,e){return!(!m.test(t)&&!f.test(t))&&(e.type="video/ovp",!0)}(t,e)||function(t,e){return!/[aeiou]/.test(t.toLowerCase())&&(!(!v.test(t)&&!y.test(t))&&(e&&(e.type="video/ovp"),!0))}(t,e)||h(e)}function g(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 _(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 b(t){return t.live}var E=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 O(t,e){const n=null==e?void 0:e.src;if(h(e))return function(t,e){const n=g(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);j(t,n)}(t,e);n&&(t.setState("is-source-processing",!0),Pipe.of(n).fmap(d).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>{return 200==e?j(t,n):(r=n,(o=t).setState("is-source-processing",!1),r.message?o.emit("ovp:error",r):r.status?o.emit("ovp:error",new Error(u[r.status])):o.emit("ovp:error",r));var o,r})))}function j(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),r=(null==t?void 0:t.playlist)||{},i=n(e,r),s=((null==i?void 0:i.playlist)||[]).map(t=>{e.ima&&Object.assign(t,{ima:e.ima});const n=p(t,o);return delete n.playlist,n});return delete i.ima,Object.assign(i,{playlist:s})}(t.opts,e))}(t,e):b(e)?function(t,e){var n,o;const r=(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);r&&(e.live_start_time=Pipe.of(r).fmap(_).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e)}const A={};function P(t,e,n){"object"!=typeof A[e]&&(A[e]=n);const o=t.opts,r=(null==o?void 0:o.metadata)||{};r.player_id=e,o.metadata=r,n.title&&delete n.title,n.description&&delete n.description;const i=Object.assign(o,n);t.setOpts(i),n.autoplay&&t.togglePlay(!0)}let S=!1;function T(t,e,n){L()||Pipe.of("recommendation").fmap(a,e,n).fmap(s).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,n;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,description:null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.description,metadata:t.metadata||{},chapters:t.chapters,thumbnails:t.thumbnails,subtitles:t.subtitles}}))})}(t,e)).catch(C))}function L(){return S}function C(t){S=!0,console.error("Failed to load recommendations: %j",t)}function x(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function M(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const k="flowplayer-live-countdown";function I(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function D(t,e){let n=0;function o(){const o=I(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=M(t,k);if(o&&o.remove(),t.root.classList.remove("is-livecountdown"),n)return t.setState("is-source-processing",!1);t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var r,i,s;r=t,i=t.root,s=o,i.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:q(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function q(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+x(e.hours)+":"+x(e.minutes)+":"+x(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 R=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(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 V=["*.lwcdn.com","*.flowplayer.com","*.wowza.com"];function N(){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}}function U(t){const e=document.createElement("a");e.href=t;const n=e.pathname&&e.pathname.split(".");return n.length>1&&n[n.length-1]}function W(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const $=e=>{var{src:n}=e,o=t(e,["src"]);return[Object.assign({src:n,type:n?W("video/"+U(n)):""},o)]};function F(t){return $({src:t})}function z(e){var{src:n,type:o}=e,r=t(e,["src","type"]);return n&&o?[Object.assign({src:n,type:o},r)]:o&&!n?[Object.assign({type:o},r)]:$(Object.assign({src:n},r))}var H;!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(H||(H={}));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,k,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||h(o)||(o.src=[t.player_id,o.src].join("/")),O(n,o)}wants(t,e,n){return w(t,e)}init(e,o,r){const i=new WebsocketBridge(r);let c=Object.assign({},e);const l=function(t){return c?(e.autoplay!==c.autoplay&&(c.autoplay=e.autoplay),delete c.src,n(t,c)):t};r.on("src",()=>{(r.currentSrc||r.root.classList.contains("is-livecountdown"))&&(c=!1)}),r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),e.recommendations&&(e.recommendations=!1)})),r.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))})),r.on("ovp:message:realtime",(function({data:t}){var n;const o=null==t?void 0:t.event,i=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const t=Object.assign(s,i),o=Object.assign(e,{metadata:t});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=_(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(t){const n=e;if(b(n)){if(B(n))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;var n;if(e.src&&(e.src=(n=e.src,"string"==typeof n?F(n):Array.isArray(n)||"object"!=typeof n?n.reduce((function(t,e){return"string"==typeof e&&(e=F(e)),"object"!=typeof e||Array.isArray(e)||(e=z(e)),t.concat(e)}),[]):z(n)).map(t=>(t.src&&t.src.startsWith("//")&&(t.src="https:"+t.src),t))),0==r.reaper||"object"!=typeof e||I(e)>0)return;const o=l(e);r.setOpts(o),r.setAttrs(o),o.src&&r.setSrc(o.src),r.setState("is-source-processing",!1)})),r.on("config",(function({data:t}){var n,i;if("string"==typeof e.src&&w(e.src,{}))return;if((null==t?void 0:t.domains)&&(null==t?void 0:t.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(V).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)})})(N(),t.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 r=document.createElement("p");r.textContent="Are you the site owner?";const i=document.createElement("a");i.classList.add("troubleshoot"),i.target="_blank",i.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,i.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,r,i,s)}({root:o,video:r,data:{details:`Hostname ${N()} is not allowed to load player ${null===(n=t.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});if(e.src&&Q(e.src))return;const c=null==t?void 0:t.brand_color;return c&&r.root.style.setProperty("--fp-brand-color","#"==c[0]?c:"#"+c),"string"==typeof e.player_id&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)!==e.player_id?function(t,e){if("object"==typeof A[e])return console.debug("using Cache(%s)",e),P(t,e,A[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const n=e.data;if(!n||0==r.reaper)return;const{playlist:o}=n,i=t(n,["playlist"]),s=l(i);Array.isArray(s.playlist)&&(s.playlist=i),r.setOpts(s),r.setAttrs(s);const a={type:"flowplayer/playlist",items:o};r.setSrc(a),r.setState("is-source-processing",!1)})),r.on("ovp:live:countdown:start",(function(t){const n=t.data;if(!n||0==r.reaper)return;const i=l(n);if(r.setOpts(i),r.setAttrs(i),I(n)<=0)return r.emit("ovp:request:media:complete",n);M(r,k)||(o.appendChild(R(r,k)),D(r,e))})),r.on("timeupdate",(function(){var t,n,o;const i=e;b(i)?B(i)||(r.togglePlay(!1),r.emit("ended")):e.recommendations&&(null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)&&(Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||L()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.player_id)&&T(r,e.metadata.media_id,e.metadata.player_id))})),r.on("reap",(function(){i.disconnect()}))}}function B(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)||_(o)>Date.now()}_OVP.events=E;const Q=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;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,_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";function t(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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(r=>{if(e(t[r])&&e(o[r]))return t[r]=n(t[r],o[r]);t[r]=o[r]}),t):t,{});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 o="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),r=window,i=r._flowplayerTimekeeper||(r._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),c()+"/web/public/native/config"+t}const c=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(o)),n=await e,r=parseInt(n.headers.get("age")||"0"),s=await n.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function d(t){return~t.indexOf("/")?t:"/media/"+t}var u={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function p(t,e){var o,r;e="object"==typeof e?e:{};const i={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:r,ad_keywords:i}){return{ad_keywords:i||"",media_id:t||"",category:r||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},a=e.embed||{};return delete a.src,n(s,i,t,(delete(c=e).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),a);var c}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,v=/^[A-Za-z0-9]{8}$/,y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[A-Za-z0-9]{8}$/;function h(t){return"object"==typeof t&&"ovp/base64"==t.type}function w(t,e){return function(t,e){return!(!m.test(t)&&!f.test(t))&&(e.type="video/ovp",!0)}(t,e)||function(t,e){return!/[aeiou]/.test(t.toLowerCase())&&(!(!v.test(t)&&!y.test(t))&&(e&&(e.type="video/ovp"),!0))}(t,e)||h(e)}function g(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 _(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 b(t){return t.live}var E=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 O(t,e){const n=null==e?void 0:e.src;if(h(e))return function(t,e){const n=g(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);j(t,n)}(t,e);n&&(t.setState("is-source-processing",!0),Pipe.of(n).fmap(d).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>{return 200==e?j(t,n):(r=n,(o=t).setState("is-source-processing",!1),r.message?o.emit("ovp:error",r):r.status?o.emit("ovp:error",new Error(u[r.status])):o.emit("ovp:error",r));var o,r})))}function j(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),r=(null==t?void 0:t.playlist)||{},i=n(e,r),s=((null==i?void 0:i.playlist)||[]).map(t=>{e.ima&&Object.assign(t,{ima:e.ima});const n=p(t,o);return delete n.playlist,n});return delete i.ima,Object.assign(i,{playlist:s})}(t.opts,e))}(t,e):b(e)?function(t,e){var n,o;const r=(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);r&&(e.live_start_time=Pipe.of(r).fmap(_).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e)}const A={};function P(t,e,n){"object"!=typeof A[e]&&(A[e]=n);const o=t.opts,r=(null==o?void 0:o.metadata)||{};r.player_id=e,o.metadata=r,n.title&&delete n.title,n.description&&delete n.description;const i=Object.assign(o,n);t.setOpts(i),n.autoplay&&t.togglePlay(!0)}let S=!1;function T(t,e,n){L()||Pipe.of("recommendation").fmap(a,e,n).fmap(s).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,n;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,description:null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.description,metadata:t.metadata||{},chapters:t.chapters,thumbnails:t.thumbnails,subtitles:t.subtitles}}))})}(t,e)).catch(C))}function L(){return S}function C(t){S=!0,console.error("Failed to load recommendations: %j",t)}function x(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function M(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const k="flowplayer-live-countdown";function I(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function D(t,e){let n=0;function o(){const o=I(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=M(t,k);if(o&&o.remove(),t.root.classList.remove("is-livecountdown"),n)return t.setState("is-source-processing",!1);t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var r,i,s;r=t,i=t.root,s=o,i.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:q(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function q(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+x(e.hours)+":"+x(e.minutes)+":"+x(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 R=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(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 N=["*.lwcdn.com","*.flowplayer.com","*.wowza.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}}function U(t){const e=document.createElement("a");e.href=t;const n=e.pathname&&e.pathname.split(".");return n.length>1&&n[n.length-1]}function W(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const $=e=>{var{src:n}=e,o=t(e,["src"]);return[Object.assign({src:n,type:n?W("video/"+U(n)):""},o)]};function F(t){return $({src:t})}function z(e){var{src:n,type:o}=e,r=t(e,["src","type"]);return n&&o?[Object.assign({src:n,type:o},r)]:o&&!n?[Object.assign({type:o},r)]:$(Object.assign({src:n},r))}var H,B;!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(H||(H={}));const Q=((B=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,k,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||h(o)||(o.src=[t.player_id,o.src].join("/")),O(n,o)}wants(t,e,n){return w(t,e)}init(e,o,r){const i=new WebsocketBridge(r);let c=Object.assign({},e);const l=function(t){return c?(e.autoplay!==c.autoplay&&(c.autoplay=e.autoplay),delete c.src,n(t,c)):t};r.on("src",()=>{(r.currentSrc||r.root.classList.contains("is-livecountdown"))&&(c=!1)}),r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),e.recommendations&&(e.recommendations=!1)})),r.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))})),r.on("ovp:message:realtime",(function({data:t}){var n;const o=null==t?void 0:t.event,i=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const t=Object.assign(s,i),o=Object.assign(e,{metadata:t});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=_(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(t){const n=e;if(b(n)){if(G(n))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;var n;if(e.src&&(e.src=(n=e.src,"string"==typeof n?F(n):Array.isArray(n)||"object"!=typeof n?n.reduce((function(t,e){return"string"==typeof e&&(e=F(e)),"object"!=typeof e||Array.isArray(e)||(e=z(e)),t.concat(e)}),[]):z(n)).map(t=>(t.src&&t.src.startsWith("//")&&(t.src="https:"+t.src),t))),0==r.reaper||"object"!=typeof e||I(e)>0)return;const o=l(e);r.setOpts(o),r.setAttrs(o),o.src&&r.setSrc(o.src),r.setState("is-source-processing",!1)})),r.on("config",(function({data:t}){var n,i;if("string"==typeof e.src&&w(e.src,{}))return;if((null==t?void 0:t.domains)&&(null==t?void 0:t.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(N).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(),t.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 r=document.createElement("p");r.textContent="Are you the site owner?";const i=document.createElement("a");i.classList.add("troubleshoot"),i.target="_blank",i.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,i.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,r,i,s)}({root:o,video:r,data:{details:`Hostname ${V()} is not allowed to load player ${null===(n=t.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});if(e.src&&J(e.src))return;const c=null==t?void 0:t.brand_color;return c&&r.root.style.setProperty("--fp-brand-color","#"==c[0]?c:"#"+c),"string"==typeof e.player_id&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)!==e.player_id?function(t,e){if("object"==typeof A[e])return console.debug("using Cache(%s)",e),P(t,e,A[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const n=e.data;if(!n||0==r.reaper)return;const{playlist:o}=n,i=t(n,["playlist"]),s=l(i);Array.isArray(s.playlist)&&(s.playlist=i),r.setOpts(s),r.setAttrs(s);const a={type:"flowplayer/playlist",items:o};r.setSrc(a),r.setState("is-source-processing",!1)})),r.on("ovp:live:countdown:start",(function(t){const n=t.data;if(!n||0==r.reaper)return;const i=l(n);if(r.setOpts(i),r.setAttrs(i),I(n)<=0)return r.emit("ovp:request:media:complete",n);M(r,k)||(o.appendChild(R(r,k)),D(r,e))})),r.on("timeupdate",(function(){var t,n,o;const i=e;b(i)?G(i)||(r.togglePlay(!1),r.emit("ended")):e.recommendations&&(null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)&&(Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||L()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.player_id)&&T(r,e.metadata.media_id,e.metadata.player_id))})),r.on("reap",(function(){i.disconnect()}))}}).events=E,B);function G(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)||_(o)>Date.now()}const J=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;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,Q)}));
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
package/plugins/qsel.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
package/plugins/qul.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { MediaKeyFunc } from 'hls.js';
2
2
 
3
- declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
3
+ declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
4
+ infer Current,
5
+ ...infer Remaining
6
+ ] ? Current & ArrayToIntersection<Remaining> : unknown;
4
7
 
5
8
  declare type Autoplay = BitOpts | boolean;
6
9
 
@@ -225,11 +228,11 @@ declare type PlayerState = string;
225
228
 
226
229
  declare type PlayerWith<T> = T & Player;
227
230
 
228
- declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, _uPluginPlayerAPIExtension extends KeyValue = KeyValue> {
231
+ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
229
232
  /**
230
233
  * a plugin must always implement the init method so a player instance knows how to initialize it
231
234
  */
232
- init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
235
+ init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
233
236
  }
234
237
 
235
238
  declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {