@flowplayer/player 3.23.1-rc → 3.24.0-rc.2

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 (86) hide show
  1. package/core/events.js +148 -74
  2. package/core.js +1 -1
  3. package/default.js +1 -1
  4. package/embed.js +2 -2
  5. package/index.d.ts +8 -37
  6. package/package.json +1 -1
  7. package/plugins/ads.d.ts +13 -42
  8. package/plugins/ads.js +2 -2
  9. package/plugins/airplay.d.ts +8 -42
  10. package/plugins/airplay.js +1 -1
  11. package/plugins/analytics.d.ts +8 -42
  12. package/plugins/analytics.js +1 -1
  13. package/plugins/asel.d.ts +8 -42
  14. package/plugins/asel.js +1 -1
  15. package/plugins/audio.d.ts +8 -42
  16. package/plugins/audio.js +1 -1
  17. package/plugins/chapters.d.ts +8 -42
  18. package/plugins/chapters.js +1 -1
  19. package/plugins/chromecast.d.ts +8 -42
  20. package/plugins/chromecast.js +1 -1
  21. package/plugins/comscore.d.ts +8 -42
  22. package/plugins/comscore.js +1 -1
  23. package/plugins/consent.d.ts +8 -42
  24. package/plugins/consent.js +1 -1
  25. package/plugins/context-menu.d.ts +8 -42
  26. package/plugins/context-menu.js +1 -1
  27. package/plugins/cuepoints.d.ts +8 -42
  28. package/plugins/cuepoints.js +1 -1
  29. package/plugins/dash.d.ts +8 -42
  30. package/plugins/dash.js +1 -1
  31. package/plugins/drm.d.ts +70 -8
  32. package/plugins/drm.js +1 -1
  33. package/plugins/endscreen.d.ts +8 -42
  34. package/plugins/endscreen.js +1 -1
  35. package/plugins/fas.d.ts +8 -42
  36. package/plugins/fas.js +1 -1
  37. package/plugins/float-on-scroll.d.ts +8 -42
  38. package/plugins/float-on-scroll.js +1 -1
  39. package/plugins/ga4.d.ts +8 -42
  40. package/plugins/ga4.js +1 -1
  41. package/plugins/gemius.d.ts +8 -42
  42. package/plugins/gemius.js +1 -1
  43. package/plugins/google-analytics.d.ts +8 -42
  44. package/plugins/google-analytics.js +1 -1
  45. package/plugins/hls.d.ts +8 -42
  46. package/plugins/hls.js +1 -1
  47. package/plugins/id3.d.ts +8 -42
  48. package/plugins/id3.js +1 -1
  49. package/plugins/iframe.d.ts +8 -42
  50. package/plugins/iframe.js +1 -1
  51. package/plugins/keyboard.d.ts +8 -42
  52. package/plugins/keyboard.js +1 -1
  53. package/plugins/media-session.d.ts +8 -42
  54. package/plugins/media-session.js +1 -1
  55. package/plugins/message.d.ts +8 -42
  56. package/plugins/message.js +1 -1
  57. package/plugins/ovp.d.ts +8 -42
  58. package/plugins/ovp.js +1 -1
  59. package/plugins/playlist.d.ts +95 -43
  60. package/plugins/playlist.js +1 -1
  61. package/plugins/preview.d.ts +8 -42
  62. package/plugins/preview.js +1 -1
  63. package/plugins/qsel.d.ts +8 -42
  64. package/plugins/qsel.js +1 -1
  65. package/plugins/qul.d.ts +8 -42
  66. package/plugins/qul.js +1 -1
  67. package/plugins/rts.d.ts +8 -42
  68. package/plugins/rts.js +1 -1
  69. package/plugins/share.d.ts +8 -42
  70. package/plugins/share.js +1 -1
  71. package/plugins/speed.d.ts +8 -42
  72. package/plugins/speed.js +1 -1
  73. package/plugins/ssai.d.ts +8 -42
  74. package/plugins/ssai.js +1 -1
  75. package/plugins/subtitles.d.ts +15 -45
  76. package/plugins/subtitles.js +1 -1
  77. package/plugins/thumbnails.d.ts +8 -42
  78. package/plugins/thumbnails.js +1 -1
  79. package/plugins/tizen.d.ts +8 -42
  80. package/plugins/tizen.js +1 -1
  81. package/plugins/vtsel.d.ts +8 -42
  82. package/plugins/vtsel.js +1 -1
  83. package/plugins/webos.d.ts +8 -42
  84. package/plugins/webos.js +1 -1
  85. package/util/loader.d.ts +8 -42
  86. package/util/loader.js +9 -8
@@ -3,8 +3,6 @@
3
3
  import type { BitrateInfo } from 'dashjs';
4
4
  import type { Get } from 'type-fest';
5
5
  import type { Level } from 'hls.js';
6
- import type { MediaKeyFunc } from 'hls.js';
7
- import type { SetFieldType } from 'type-fest';
8
6
  import type { TupleToUnion } from 'type-fest';
9
7
 
10
8
  /* Excluded from this release type: AnyLoader */
@@ -270,41 +268,6 @@ declare const DESTROYED = "is-destroyed";
270
268
 
271
269
  declare const DISABLED = "is-disabled";
272
270
 
273
- /**
274
- * @public
275
- */
276
- declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
277
-
278
- /**
279
- * @public
280
- */
281
- declare type DRMConfiguration = {
282
- license_server: string;
283
- http_headers?: Record<string, string>;
284
- certificate?: string;
285
- vendor?: string | DRMVendorImplementation;
286
- request_media_key_system_access_function?: MediaKeyFunc;
287
- query_params?: Record<string, string>;
288
- };
289
-
290
- /**
291
- * @public
292
- */
293
- declare type DRMSourceConfiguration = {
294
- [keysystem in DRM_KEYSYSTEM]?: DRMConfiguration;
295
- };
296
-
297
- /**
298
- * @public
299
- */
300
- declare type DRMVendorImplementation = {
301
- fairplay_fetch_certificate: (url: string, cb: (certificate_data: Uint8Array) => void) => void;
302
- fairplay_request_license: (url: string, params: {
303
- message: any;
304
- assetId: string;
305
- }, cb: (license_data: Uint8Array) => void) => void;
306
- };
307
-
308
271
  /**
309
272
  * @public
310
273
  */
@@ -531,13 +494,13 @@ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Co
531
494
  * @param selector - query selector of the HTML element where player will render
532
495
  * @param config - Configuration of the flowplayer and the attached plugins
533
496
  */
534
- (selector: string, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
497
+ (selector: string, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
535
498
  /**
536
499
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
537
500
  * @param element - HTML element where player will render
538
501
  * @param config - Configuration of the flowplayer and the attached plugins
539
502
  */
540
- (element: HTMLElement, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
503
+ (element: HTMLElement, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
541
504
  }
542
505
 
543
506
  /**
@@ -1154,6 +1117,11 @@ declare type PlayerState = FlowplayerStates[keyof FlowplayerStates];
1154
1117
  */
1155
1118
  declare type PlayerWith<T> = T & Player;
1156
1119
 
1120
+ declare type PlayerWithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = Omit<PluginPlayer, "opts" | "setOpts"> & {
1121
+ opts: PluginConfig;
1122
+ setOpts: (config: PluginConfig) => void;
1123
+ };
1124
+
1157
1125
  declare const PLAYING = "is-playing";
1158
1126
 
1159
1127
  /**
@@ -1184,6 +1152,7 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer ex
1184
1152
  */
1185
1153
  declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1186
1154
  new (umd: FlowplayerUMD, player: Player): Plugin_2<PluginConfig, PluginPlayer>;
1155
+ pluginName: string;
1187
1156
  }
1188
1157
 
1189
1158
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -1482,7 +1451,6 @@ declare type SourceObj<T = unknown> = {
1482
1451
  * the MIME type (example `video/mp4` or `application/x-mpegurl`)
1483
1452
  */
1484
1453
  type?: string;
1485
- drm?: DRMSourceConfiguration;
1486
1454
  } & T;
1487
1455
 
1488
1456
  /**
@@ -1706,6 +1674,4 @@ declare const WILL_PLAY = "will-play";
1706
1674
 
1707
1675
  declare const WILL_SEEK = "will-seek";
1708
1676
 
1709
- declare type WithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = SetFieldType<SetFieldType<PluginPlayer, "opts", PluginConfig>, "setOpts", (config: PluginConfig) => void>;
1710
-
1711
1677
  export { }
@@ -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.chapters=t())}(this,(function(){"use strict";function e(){}var t;function n(e,n){if(function(e){return Object.values(t).includes(e)}(n=n||t.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=n:e.setAttribute("crossorigin",n),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function i(t,i){const s=document.createElement("track");s.className="fp-track renderable",s.kind=i.kind||"captions",s.label=i.label||i.lang||"",s.lang=i.lang||"",s.id=["fp",i.lang].join("-");const o=s.track;return o.removeCue=e,"string"!=typeof i.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(t,i.src)&&(n(t),i.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in i&&n(t,i.crossorigin),Object.keys(i).forEach(e=>{"default"!==e&&(s[e]=i[e])}),o.mode=i.default?"hidden":"disabled",t.appendChild(s),s}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(t||(t={}));var s=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});function o(e,t,n){const r=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(r),e}function a(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function c(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}!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){}}();const l="flowplayer-timeline-bar",u="is-source-processing";class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const d={passive:!0};var h;function p(t,n){let r=0,i=-1,s=-1;const o=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),a=t.classList;t.id=o,a.remove(h.GRABBING),a.remove(h.TOUCHING);const c=n.onseek||e,l=n.onstart||e,u=n.onend||e,p=n.onmouse||e,_=n.ontouch||e,v=n.ontouchend||e;function g(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function y(e){const n=g(e);n!=s&&(c(t,n),s=n)}return t.addEventListener("touchstart",(function(e){f(t,e)&&(a.add(h.TOUCHING),m(t.parentElement)&&(a.add(h.GRABBING),_(t,g(e)),l(t,g(e)),y(e)))}),d),t.addEventListener("touchmove",(function(e){y(e),p(t,g(e))}),d),t.addEventListener("touchend",(function(e){setTimeout((function(){a.remove(h.TOUCHING)}),500),f(t,e)&&(a.remove(h.GRABBING),v(t,g(e)),u(t,g(e)),i=0)}),d),t.addEventListener("touchcancel",(function(){a.remove(h.GRABBING,h.TOUCHING),i=0}),d),t.addEventListener("mousedown",(function(e){a.contains(h.TOUCHING)||(document.addEventListener("mousemove",y),a.add(h.GRABBING),l(t,g(e)),e.preventDefault(),y(e))})),t.addEventListener("mousemove",(function(e){a.contains(h.TOUCHING)||p(t,g(e))})),document.addEventListener("mouseup",(function(e){a.contains(h.TOUCHING)||(document.removeEventListener("mousemove",y),a.contains(h.GRABBING)&&(a.remove(h.GRABBING),u(t,g(e)),i=0))})),t}function f(e,t){const n=t.target;return!!n&&(n&&!n.closest(e.id)||!m(e.parentElement)||!e.classList.contains(h.TOUCHING))}function m(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}function _(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function v(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const n=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,n>=1?(r-=60*n,t+n+":"+_(r)+":"+_(e)):t+_(r)+":"+_(e)}function g(e,t){if(!e.parentElement)return;const n=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-n+"%",e.style.display="block"}function y(e,t){if(isNaN(e.duration))return;const n=e.buffered;n.length&&(t.style.width=Math.min(n.end(n.length-1)/e.duration*100,100)+"%")}function E(e,t){e.style.width="0",t.style.display="none"}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(h||(h={}));function b(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState("is-chromecast-playing")||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),i=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof i||r-i<0?n.start(0):r-i}}function A(e,t,n){if(!t.seekable||0==t.seekable.length)return;g(n,e);const r=b(t),i=(100-Math.max(0,Math.min(e,100)))/100*(r.head-r.tail);n.innerText="-"+v(i)}function w(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const n=b(e);return n.tail+t*(n.head-n.tail)}(t,e)}function k(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=c("fp-buffer"),this.progress=c("fp-progress","fp-color"),this.tooltipEle=c("fp-timestamp"),this.proposedSeekBar=c("fp-hover"),this.dragger=c("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("core.timeline_aria_label","Seek slider")),this.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);const n=requestAnimationFrame;let r=void 0;const i=()=>{var n;0==e.reaper||t.live||(n=e,this.progress.style.width=n.currentTime/n.duration*100+"%",r=void 0,e.paused||this.classList.contains(h.GRABBING)||r||(r=setTimeout(i,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);p(this,{onseek:(n,r)=>{if(s())switch(!!t.live){case!0:A(r,e,this.tooltipEle);break;case!1:!function(e,t,n){const r=t.duration*(e/100);if(t.disabled&&r>t.currentTime)return!1;n.style.width=e+"%",t.currentTime=r}(r,e,this.progress),g(this.tooltipEle,r)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),!e.hasState("is-casting")&&e.setState("is-seeking",!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,s){n(i),0!=t.seekable&&t.live&&w(s,e)},ontouchend:()=>{t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>e.emit("timeline/gesture/end"),0)},onmouse:(n,r)=>{if(s()&&(e.emit("timeline/gesture/move",{percent:r}),!this.classList.contains(h.GRABBING)))switch(!!t.live){case!0:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),A(r,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),function(e,t,n){isNaN(e)||isNaN(t.duration)||(g(n,e),n.textContent=v(e/100*t.duration))}(r,e,this.tooltipEle)}}}),e.on("config",(function(e){e.data&&(t=e.data)})),e.on("playing",()=>n(i)),e.on("progress",()=>{0==e.reaper||t.live||y(e,this.bufferEle)}),e.on("dvr",e=>{this.progress.style.width=e.detail+"%"}),e.on("timeupdate",()=>{0!=e.reaper&&(n(i),this.setAttribute("aria-valuenow",e.currentTime+""),this.setAttribute("aria-valuetext",Math.round(e.currentTime)+" "+e.i18n("core.seconds","Seconds")),t.live||y(e,this.bufferEle))}),e.on("loadedmetadata",()=>{0!=e.reaper&&(t.live||y(e,this.bufferEle))}),e.on("durationchange",t=>{if(0==e.reaper)return;const n=function(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}(e)?function(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:b(e).head}(e):t.data||e.duration;isNaN(n)||(this.setAttribute("aria-valuemax",n+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener("mouseleave",()=>{e.emit("timeline/gesture/end"),t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let n;this.addEventListener("chapters:new",e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const r=document.createElement("div");r.className="fp-chapter",r.style.left=e.left,r.style.bottom=r.style.top="0",r.style.width=e.width,r.title=e.title,r.onmouseover=()=>{t.innerText=e.title},r.onmouseleave=()=>{t.innerText=n||""},this.appendChild(r)})}),this.addEventListener("chapter:changed",r=>{var i;const s=r.data;s&&(t.parentNode||(null===(i=a(e,"flowplayer-control"))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),n=s,t.innerText=s)})}}var T;const N=((T=class Chapters{constructor(t){this._track_added_handler=e,this._cue_changed_handler=e,this.chapters=[],this.render=this.render.bind(this),t.customElements.get(l)===l&&(((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(t,"flowplayer-chapters-timeline-bar",FlowplayerChaptersTimelineBar),t.customElements.set(l,"flowplayer-chapters-timeline-bar"))}init(e,t,n){this._root=t,this._player=n,this._timeline=a(n,l),this._track_added_handler=this.track_added.bind(this,n),this._cue_changed_handler=this.cue_changed.bind(this,n),n.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(n,e),n.chapters=this,n.on("config",e=>{e.data&&this.wireup(n,e.data)}),n.on(["playlist/advance","src"],e=>{n.currentSrc&&("src"===e.type&&["is-playlist",u].some(e=>n.root.classList.contains(e))||(this._current_chapters_src=void 0,delete n.opts.chapters,this.wiredown(n)))}),n.on("reap",()=>{this.wiredown(n),n.textTracks.removeEventListener("addtrack",this._track_added_handler),n.off("durationchange",this.render)}),n.on("durationchange",this.render)}track_added(e,t){}cue_changed(e,t){var n;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&o(this._timeline,"chapter:changed",null===(n=this.current_cue)||void 0===n?void 0:n.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(o(this._timeline,"chapters:new",this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const n=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;n&&n.src!==this._current_chapters_src&&(this._current_chapters_track=i(e,Object.assign(Object.assign({},n),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=n.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track),this._current_chapters_track=void 0)}}).events=s,T);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const 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,N)}));
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.chapters=t())}(this,(function(){"use strict";function e(){}var t;function n(e,n){if(function(e){return Object.values(t).includes(e)}(n=n||t.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=n:e.setAttribute("crossorigin",n),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function i(t,i){const s=document.createElement("track");s.className="fp-track renderable",s.kind=i.kind||"captions",s.label=i.label||i.lang||"",s.lang=i.lang||"",s.id=["fp",i.lang].join("-");const o=s.track;return o.removeCue=e,"string"!=typeof i.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(t,i.src)&&(n(t),i.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in i&&n(t,i.crossorigin),Object.keys(i).forEach(e=>{"default"!==e&&(s[e]=i[e])}),o.mode=i.default?"hidden":"disabled",t.appendChild(s),s}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(t||(t={}));var s=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});function o(e,t,n){const r=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(r),e}function a(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function c(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}!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){}}();const l="flowplayer-timeline-bar",u="is-source-processing";class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const d={passive:!0};var h;function p(t,n){let r=0,i=-1,s=-1;const o=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),a=t.classList;t.id=o,a.remove(h.GRABBING),a.remove(h.TOUCHING);const c=n.onseek||e,l=n.onstart||e,u=n.onend||e,p=n.onmouse||e,_=n.ontouch||e,v=n.ontouchend||e;function g(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function y(e){const n=g(e);n!=s&&(c(t,n),s=n)}return t.addEventListener("touchstart",(function(e){f(t,e)&&(a.add(h.TOUCHING),m(t.parentElement)&&(a.add(h.GRABBING),_(t,g(e)),l(t,g(e)),y(e)))}),d),t.addEventListener("touchmove",(function(e){y(e),p(t,g(e))}),d),t.addEventListener("touchend",(function(e){setTimeout((function(){a.remove(h.TOUCHING)}),500),f(t,e)&&(a.remove(h.GRABBING),v(t,g(e)),u(t,g(e)),i=0)}),d),t.addEventListener("touchcancel",(function(){a.remove(h.GRABBING,h.TOUCHING),i=0}),d),t.addEventListener("mousedown",(function(e){a.contains(h.TOUCHING)||(document.addEventListener("mousemove",y),a.add(h.GRABBING),l(t,g(e)),e.preventDefault(),y(e))})),t.addEventListener("mousemove",(function(e){a.contains(h.TOUCHING)||p(t,g(e))})),document.addEventListener("mouseup",(function(e){a.contains(h.TOUCHING)||(document.removeEventListener("mousemove",y),a.contains(h.GRABBING)&&(a.remove(h.GRABBING),u(t,g(e)),i=0))})),t}function f(e,t){const n=t.target;return!!n&&(n&&!n.closest(e.id)||!m(e.parentElement)||!e.classList.contains(h.TOUCHING))}function m(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}function _(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function v(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const n=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,n>=1?(r-=60*n,t+n+":"+_(r)+":"+_(e)):t+_(r)+":"+_(e)}function g(e,t){if(!e.parentElement)return;const n=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-n+"%",e.style.display="block"}function y(e,t){if(isNaN(e.duration))return;const n=e.buffered;n.length&&(t.style.width=Math.min(n.end(n.length-1)/e.duration*100,100)+"%")}function E(e,t){e.style.width="0",t.style.display="none"}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(h||(h={}));function b(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState("is-chromecast-playing")||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),i=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof i||r-i<0?n.start(0):r-i}}function A(e,t,n){if(!t.seekable||0==t.seekable.length)return;g(n,e);const r=b(t),i=(100-Math.max(0,Math.min(e,100)))/100*(r.head-r.tail);n.innerText="-"+v(i)}function w(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const n=b(e);return n.tail+t*(n.head-n.tail)}(t,e)}function k(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=c("fp-buffer"),this.progress=c("fp-progress","fp-color"),this.tooltipEle=c("fp-timestamp"),this.proposedSeekBar=c("fp-hover"),this.dragger=c("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("core.timeline_aria_label","Seek slider")),this.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);const n=requestAnimationFrame;let r=void 0;const i=()=>{var n;0==e.reaper||t.live||(n=e,this.progress.style.width=n.currentTime/n.duration*100+"%",r=void 0,e.paused||this.classList.contains(h.GRABBING)||r||(r=setTimeout(i,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);p(this,{onseek:(n,r)=>{if(s())switch(!!t.live){case!0:A(r,e,this.tooltipEle);break;case!1:!function(e,t,n){const r=t.duration*(e/100);if(t.disabled&&r>t.currentTime)return!1;n.style.width=e+"%",t.currentTime=r}(r,e,this.progress),g(this.tooltipEle,r)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),!e.hasState("is-casting")&&e.setState("is-seeking",!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,s){n(i),0!=t.seekable&&t.live&&w(s,e)},ontouchend:()=>{t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>e.emit("timeline/gesture/end"),0)},onmouse:(n,r)=>{if(s()&&(e.emit("timeline/gesture/move",{percent:r}),!this.classList.contains(h.GRABBING)))switch(!!t.live){case!0:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),A(r,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),function(e,t,n){isNaN(e)||isNaN(t.duration)||(g(n,e),n.textContent=v(e/100*t.duration))}(r,e,this.tooltipEle)}}}),e.on("config",(function(e){e.data&&(t=e.data)})),e.on("playing",()=>n(i)),e.on("progress",()=>{0==e.reaper||t.live||y(e,this.bufferEle)}),e.on("dvr",e=>{this.progress.style.width=e.detail+"%"}),e.on("timeupdate",()=>{0!=e.reaper&&(n(i),this.setAttribute("aria-valuenow",e.currentTime+""),this.setAttribute("aria-valuetext",Math.round(e.currentTime)+" "+e.i18n("core.seconds","Seconds")),t.live||y(e,this.bufferEle))}),e.on("loadedmetadata",()=>{0!=e.reaper&&(t.live||y(e,this.bufferEle))}),e.on("durationchange",t=>{if(0==e.reaper)return;const n=function(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}(e)?function(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:b(e).head}(e):t.data||e.duration;isNaN(n)||(this.setAttribute("aria-valuemax",n+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener("mouseleave",()=>{e.emit("timeline/gesture/end"),t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let n;this.addEventListener("chapters:new",e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const r=document.createElement("div");r.className="fp-chapter",r.style.left=e.left,r.style.bottom=r.style.top="0",r.style.width=e.width,r.title=e.title,r.onmouseover=()=>{t.innerText=e.title},r.onmouseleave=()=>{t.innerText=n||""},this.appendChild(r)})}),this.addEventListener("chapter:changed",r=>{var i;const s=r.data;s&&(t.parentNode||(null===(i=a(e,"flowplayer-control"))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),n=s,t.innerText=s)})}}var T;const N=((T=class Chapters{constructor(t){this._track_added_handler=e,this._cue_changed_handler=e,this.chapters=[],this.render=this.render.bind(this),t.customElements.get(l)===l&&(((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(t,"flowplayer-chapters-timeline-bar",FlowplayerChaptersTimelineBar),t.customElements.set(l,"flowplayer-chapters-timeline-bar"))}init(e,t,n){this._root=t,this._player=n,this._timeline=a(n,l),this._track_added_handler=this.track_added.bind(this,n),this._cue_changed_handler=this.cue_changed.bind(this,n),n.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(n,e),n.chapters=this,n.on("config",e=>{e.data&&this.wireup(n,e.data)}),n.on(["playlist/advance","src"],e=>{n.currentSrc&&("src"===e.type&&["is-playlist",u].some(e=>n.root.classList.contains(e))||(this._current_chapters_src=void 0,delete n.opts.chapters,this.wiredown(n)))}),n.on("reap",()=>{this.wiredown(n),n.textTracks.removeEventListener("addtrack",this._track_added_handler),n.off("durationchange",this.render)}),n.on("durationchange",this.render)}track_added(e,t){}cue_changed(e,t){var n;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&o(this._timeline,"chapter:changed",null===(n=this.current_cue)||void 0===n?void 0:n.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(o(this._timeline,"chapters:new",this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const n=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;n&&n.src!==this._current_chapters_src&&(this._current_chapters_track=i(e,Object.assign(Object.assign({},n),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=n.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track),this._current_chapters_track=void 0)}}).events=s,T.pluginName="chapters",T);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const 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,N)}));
@@ -3,8 +3,6 @@
3
3
  import type { BitrateInfo } from 'dashjs';
4
4
  import type { Get } from 'type-fest';
5
5
  import type { Level } from 'hls.js';
6
- import type { MediaKeyFunc } from 'hls.js';
7
- import type { SetFieldType } from 'type-fest';
8
6
  import type { TupleToUnion } from 'type-fest';
9
7
 
10
8
  /* Excluded from this release type: AnyLoader */
@@ -331,41 +329,6 @@ declare const DESTROYED = "is-destroyed";
331
329
 
332
330
  declare const DISABLED = "is-disabled";
333
331
 
334
- /**
335
- * @public
336
- */
337
- declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
338
-
339
- /**
340
- * @public
341
- */
342
- declare type DRMConfiguration = {
343
- license_server: string;
344
- http_headers?: Record<string, string>;
345
- certificate?: string;
346
- vendor?: string | DRMVendorImplementation;
347
- request_media_key_system_access_function?: MediaKeyFunc;
348
- query_params?: Record<string, string>;
349
- };
350
-
351
- /**
352
- * @public
353
- */
354
- declare type DRMSourceConfiguration = {
355
- [keysystem in DRM_KEYSYSTEM]?: DRMConfiguration;
356
- };
357
-
358
- /**
359
- * @public
360
- */
361
- declare type DRMVendorImplementation = {
362
- fairplay_fetch_certificate: (url: string, cb: (certificate_data: Uint8Array) => void) => void;
363
- fairplay_request_license: (url: string, params: {
364
- message: any;
365
- assetId: string;
366
- }, cb: (license_data: Uint8Array) => void) => void;
367
- };
368
-
369
332
  /**
370
333
  * @public
371
334
  */
@@ -592,13 +555,13 @@ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Co
592
555
  * @param selector - query selector of the HTML element where player will render
593
556
  * @param config - Configuration of the flowplayer and the attached plugins
594
557
  */
595
- (selector: string, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
558
+ (selector: string, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
596
559
  /**
597
560
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
598
561
  * @param element - HTML element where player will render
599
562
  * @param config - Configuration of the flowplayer and the attached plugins
600
563
  */
601
- (element: HTMLElement, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
564
+ (element: HTMLElement, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
602
565
  }
603
566
 
604
567
  /**
@@ -1217,6 +1180,11 @@ declare type PlayerState = FlowplayerStates[keyof FlowplayerStates];
1217
1180
  */
1218
1181
  declare type PlayerWith<T> = T & Player;
1219
1182
 
1183
+ declare type PlayerWithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = Omit<PluginPlayer, "opts" | "setOpts"> & {
1184
+ opts: PluginConfig;
1185
+ setOpts: (config: PluginConfig) => void;
1186
+ };
1187
+
1220
1188
  declare const PLAYING = "is-playing";
1221
1189
 
1222
1190
  /**
@@ -1247,6 +1215,7 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer ex
1247
1215
  */
1248
1216
  declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1249
1217
  new (umd: FlowplayerUMD, player: Player): Plugin_2<PluginConfig, PluginPlayer>;
1218
+ pluginName: string;
1250
1219
  }
1251
1220
 
1252
1221
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -1545,7 +1514,6 @@ declare type SourceObj<T = unknown> = {
1545
1514
  * the MIME type (example `video/mp4` or `application/x-mpegurl`)
1546
1515
  */
1547
1516
  type?: string;
1548
- drm?: DRMSourceConfiguration;
1549
1517
  } & T;
1550
1518
 
1551
1519
  /**
@@ -1779,6 +1747,4 @@ declare const WILL_PLAY = "will-play";
1779
1747
 
1780
1748
  declare const WILL_SEEK = "will-seek";
1781
1749
 
1782
- declare type WithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = SetFieldType<SetFieldType<PluginPlayer, "opts", PluginConfig>, "setOpts", (config: PluginConfig) => void>;
1783
-
1784
1750
  export { }
@@ -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.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:o}=n,r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(n,["src"]);return[Object.assign({src:o,type:o?t("video/"+e(o)):""},r)]};function o(e){return n({src:e})}class Pipe{static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}constructor(e){this.data=e}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}}const r="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:r,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const s={AAC:"aac",AC3:"ac3",E_AC3:"e_ac3",FMP4:"fmp4",MP3:"mp3",TS:"ts",TS_AAC:"ts_aac"},i={FMP4:"fmp4",MPEG2_TS:"mpeg2_ts"},c=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function l(){var e;return(null===(e=g())||void 0===e?void 0:e.getCurrentSession())||null}function u(e){return h(e).unwrap().shift()}function d(e,t){const n=e.opts.chromecast;(null==n?void 0:n.hlsSegmentFormat)&&Object.values(s).includes(n.hlsSegmentFormat.toLowerCase())&&(t.hlsSegmentFormat=n.hlsSegmentFormat),(null==n?void 0:n.hlsVideoSegmentFormat)&&Object.values(i).includes(n.hlsVideoSegmentFormat.toLowerCase())&&(t.hlsVideoSegmentFormat=n.hlsVideoSegmentFormat)}function m(){var e;return(null===(e=l())||void 0===e?void 0:e.getMediaSession())||null}function p(e){var t,n;const o=h(e).unwrap().map((function(e){return null==e?void 0:e.src})),r=null===(n=null===(t=m())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!r&&!!~o.indexOf(r)}function f(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(c))||!1}function v(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?o(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function h(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?o(e):e})).fmap(v,e).fmap((function(e){return e.filter(f)}))}function g(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function y(e,t){var n;null===(n=w.casting_player)||void 0===n||n.emit(e,t)}function S(e,t,n){e.forEach((function(e){e!==w.casting_player&&e.emit(t,n)}))}function _(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const w={remote_player:void 0,controller:void 0,listener:void 0};function E(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.remote_player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.remote_player),w.listener=b.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function b(e,t){var n;if((null===(n=g())||void 0===n?void 0:n.getCastState())!==cast.framework.CastState.NOT_CONNECTED)return"IDLE"===t.value?S(e,r):void y("chromecast:field:update",t)}function T(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function A(e){return T(e).flatMap((t,n)=>{try{const o=e.querySelector("#"+t.id);if(!(o instanceof HTMLTrackElement&&o.lang))return[];const r=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return r.trackContentType="text/vtt",r.subtype=chrome.cast.media.TextTrackType.SUBTITLES,r.trackContentId=o.src,r.name=o.label,r.language=o.lang,r}catch(e){return[]}})}function C(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=m())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var k=Object.freeze({__proto__:null,getCurrentSession:l,getMedia:u,setMediaSegmentFormat:d,getMediaSession:m,isSame:p,is_supported_media:f,injectDRMConfiguration:v,normalizeSrc:h,getCastContext:g,broadcast_to_active:y,broadcast_to_idle:S,broadcast:_,SINGLETONS:w,refresh_singletons:E,onremotechange:b,tracks:T,cast_tracks:A,editTracks:C});var O=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const L="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function P(e,t,n){if(document.querySelector("script[src='"+L+"']"))return x(n);!function(){const e=document.createElement("script");e.async=!0,e.src=L,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var o;if(!I())return;const r=(null===(o=e.chromecast)||void 0===o?void 0:o.app)||"940D4BE4",a=g();if(!a)return;a.setOptions({receiverApplicationId:r,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){_(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){E(n),_(n,"chromecast:session:changed",e)}))}(e,0,n),x(n)}}function I(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function x(e){if(I())return _(e,"chromecast:available");_(e,"chromecast:unavailable")}const D="is-chromecast-playing";function M(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const o=function(e){var t;const n=e.seekable;return n.length?e.hasState(D)||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),r=t||e.live_state.dvr_window;return{head:o,tail:"number"!=typeof r||o-r<0?n.start(0):o-r}}function N(e){const t=e.currentTime,n=M(e);return{progress:Math.min(100,Math.max(0,(t-n.tail)/(n.head-n.tail)*100)),is_live:t-n.head>=-10}}const j={player:void 0,listener:void 0};function F(e,t,n,o){var a,s,i,c,p;const f=l();if(!f)return;const v=u(e);if(!v||!v.src)return;w.casting_player=e;const h=new chrome.cast.media.MediaInfo(v.src,v.type||"");h.metadata=new chrome.cast.media.GenericMediaMetadata,function(e){j.player&&j.listener&&j.player.off("playing",j.listener);const t={currentTime:e.currentSessionTime,liveState:e.live_state,progress:N(e).progress};j.player=e,j.listener=()=>{setTimeout(()=>{!function(e,t){const n=m();if(!n)return;if(-1!==n.media.duration)return e.currentTime=t.currentTime;const o=n.liveSeekableRange;if(!o||"number"!=typeof o.end||"number"!=typeof o.start)return;if(void 0===t.liveState.dvr_window||!t.liveState.dvr)return;e.currentTime=(o.end-o.start)*(t.progress/100)}(e,t)},1e3)},e.once("playing",j.listener)}(e);const g={health:e.health,text_tracks:A(e),active_tracks:{active_audio:(null===(s=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===s?void 0:s.name)||(null===(c=null===(i=null==e?void 0:e.asel)||void 0===i?void 0:i.active_track)||void 0===c?void 0:c.lang),active_text:null===(p=T(e).find(e=>e.is_active))||void 0===p?void 0:p.label}};v.drm&&(g.drm=v.drm),localStorage.__fpChromecastDebug&&(g.debug=!0),e.opt("ads")&&(g.ads=e.opt("ads")),h.customData=g,d(e,h);const y=new chrome.cast.media.LoadRequest(h);y.customData=e.opt("chromecast",{}),y.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:y}),console.debug("cast:request(%o)",y),f.loadMedia(y).then(()=>{e.emit("remotesession:started"),e.setState("has-casted",!0),e.setState("is-casting",!0),E(t);const n=w.remote_player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),S(t,r)},o)}function R(){return!!m()}function G(){return!!l()}function q(){var e;return null===(e=l())||void 0===e?void 0:e.getCastDevice().friendlyName}function H(){var e;return(null===(e=null==k?void 0:l())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function V(){var e,t;return null===(t=null===(e=m())||void 0===e?void 0:e.media)||void 0===t?void 0:t.duration}function U(){var e;return null===(e=m())||void 0===e?void 0:e.playerState}function B(e){var t;return e?z(e):null===(t=m())||void 0===t?void 0:t.getEstimatedTime()}function z(e){const t=m();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function Y(){var e;return null===(e=m())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function J(){var e;return null===(e=m())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var X=Object.freeze({__proto__:null,load:F,has_media:R,exists:G,device_name:q,seekable_ranges:H,duration:V,state:U,currentTime:B,seek:z,play:Y,pause:J});function $(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let o="";o=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),o=o.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=o}const Q="currentTime",K="duration",W="playerState",Z="videoInfo",ee="volumeLevel",te="isMuted",ne="liveSeekableRange",oe=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=l();if(n)return n.endSession(!0);e.emit("chromecast:start"),t.target===this&&this.cast_launcher.click()}),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function re(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,o;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",o=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,o),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");P(e,0,this.flowplayer.instances),n.on("mount",(function(){const t=re(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const o=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(o),e.prepend(n)}(t,{poster:e.poster});const o=re(n,"flowplayer-header-right-zone");o&&o.prepend(oe(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),function(e,t){const n={play:function(){return new Promise(n=>p(e)?n(Y()):R()?n(F(e,t,console.debug,console.error)):(F(e,t,console.debug,console.error),void n()))},pause:function(){return p(e)?J():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:B,set:B},n.seekable={get:()=>{const e=H();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:V},n.paused={get:function(){return"PAUSED"===U()}},n.playing={get:function(){return"PLAYING"===U()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var o,r;return p(e)?n[t].get():null===(r=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.get)||void 0===r?void 0:r.call(this)},set:function(o){var r,a;return p(e)?n[t].set(o):null===(a=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.set)||void 0===a?void 0:a.call(this,o)}});const o=e[t];e[t]=function(){const r=[].slice.apply(arguments);return G()?n[t].apply(e,r):o.apply(e,r)}}))}(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1)})),n.on("chromecast:start",()=>{if(w.casting_player=n,this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),R())return F(n,this.flowplayer.instances,console.debug,console.error)}),n.on("volumechange",()=>{const e=w.remote_player,t=w.controller;if(!R()||!e||!t)return;const o=n.volume,r=n.muted;o!==e.volumeLevel&&(e.volumeLevel=o,t.setVolumeLevel()),r!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",(function(e){var t,o,r;if(R())return e.data?void C((null===(r=null===(o=null===(t=m())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=T(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):C([])})),n.on("audio:update",()=>{R()&&setTimeout(()=>{var e,t,o,r,a;const s=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,i=null===(a=null===(r=null===(o=null===(t=m())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==s?void 0:s.name):e.language===(null==s?void 0:s.lang)))||void 0===a?void 0:a.trackId;"number"==typeof i&&C([i])},0)}),n.on(r,()=>{if(n.setState("is-starting",!0),!n.hasState("is-casting"))return;const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended")),n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n)}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:o}=e.data;switch(t){case K:return void(-1!==o||n.opts.live||n.setOpts({live:!0}));case te:return n.muted=o;case ee:return n.volume=o;case ne:return n.emit("dvr/window",o.end-o.start);case Q:return Math.abs(o-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=o,n.emit("timeupdate",o);case W:return"PLAYING"==o?n.emit("playing"):"PAUSED"==o?n.emit("pause"):void 0;case Z:var r=(o||{}).fake_session||X;return $(n,{device:r.device_name(),state:r.state()}),r.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState(D,!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:if(!n.hasState("is-casting"))return;return w.casting_player=void 0,n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:if(!p(n))return;return w.casting_player=n,n.setState(n.paused?"is-paused":"is-playing",!0),n.setState("is-casting",!0),n.setState("has-casted",!0),n.setState(D,!0),n.emit("timeupdate"),n.currentSessionTime=n.currentTime,$(n,{device:q(),state:U()}),n.setState("is-starting",!1);case cast.framework.SessionState.SESSION_STARTED:if(n!==w.casting_player)return;F(n,this.flowplayer.instances,console.debug,console.error)}})}reset_state(e){e.setState(D,!1),e.setState("is-casting",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}ChromecastPlugin.apps=O,ChromecastPlugin.events=a,ChromecastPlugin.hlsSegmentFormat={audio:s,video:i};return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const 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,ChromecastPlugin)}));
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.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:o}=n,r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(n,["src"]);return[Object.assign({src:o,type:o?t("video/"+e(o)):""},r)]};function o(e){return n({src:e})}class Pipe{static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}constructor(e){this.data=e}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}}const r="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:r,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const s={AAC:"aac",AC3:"ac3",E_AC3:"e_ac3",FMP4:"fmp4",MP3:"mp3",TS:"ts",TS_AAC:"ts_aac"},i={FMP4:"fmp4",MPEG2_TS:"mpeg2_ts"},c=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function l(){var e;return(null===(e=g())||void 0===e?void 0:e.getCurrentSession())||null}function u(e){return h(e).unwrap().shift()}function d(e,t){const n=e.opts.chromecast;(null==n?void 0:n.hlsSegmentFormat)&&Object.values(s).includes(n.hlsSegmentFormat.toLowerCase())&&(t.hlsSegmentFormat=n.hlsSegmentFormat),(null==n?void 0:n.hlsVideoSegmentFormat)&&Object.values(i).includes(n.hlsVideoSegmentFormat.toLowerCase())&&(t.hlsVideoSegmentFormat=n.hlsVideoSegmentFormat)}function m(){var e;return(null===(e=l())||void 0===e?void 0:e.getMediaSession())||null}function p(e){var t,n;const o=h(e).unwrap().map((function(e){return null==e?void 0:e.src})),r=null===(n=null===(t=m())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!r&&!!~o.indexOf(r)}function f(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(c))||!1}function v(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?o(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function h(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?o(e):e})).fmap(v,e).fmap((function(e){return e.filter(f)}))}function g(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function y(e,t){var n;null===(n=w.casting_player)||void 0===n||n.emit(e,t)}function S(e,t,n){e.forEach((function(e){e!==w.casting_player&&e.emit(t,n)}))}function _(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const w={remote_player:void 0,controller:void 0,listener:void 0};function E(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.remote_player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.remote_player),w.listener=b.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function b(e,t){var n;if((null===(n=g())||void 0===n?void 0:n.getCastState())!==cast.framework.CastState.NOT_CONNECTED)return"IDLE"===t.value?S(e,r):void y("chromecast:field:update",t)}function T(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function A(e){return T(e).flatMap((t,n)=>{try{const o=e.querySelector("#"+t.id);if(!(o instanceof HTMLTrackElement&&o.lang))return[];const r=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return r.trackContentType="text/vtt",r.subtype=chrome.cast.media.TextTrackType.SUBTITLES,r.trackContentId=o.src,r.name=o.label,r.language=o.lang,r}catch(e){return[]}})}function C(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=m())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var k=Object.freeze({__proto__:null,getCurrentSession:l,getMedia:u,setMediaSegmentFormat:d,getMediaSession:m,isSame:p,is_supported_media:f,injectDRMConfiguration:v,normalizeSrc:h,getCastContext:g,broadcast_to_active:y,broadcast_to_idle:S,broadcast:_,SINGLETONS:w,refresh_singletons:E,onremotechange:b,tracks:T,cast_tracks:A,editTracks:C});var O=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const L="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function P(e,t,n){if(document.querySelector("script[src='"+L+"']"))return x(n);!function(){const e=document.createElement("script");e.async=!0,e.src=L,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var o;if(!I())return;const r=(null===(o=e.chromecast)||void 0===o?void 0:o.app)||"940D4BE4",a=g();if(!a)return;a.setOptions({receiverApplicationId:r,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){_(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){E(n),_(n,"chromecast:session:changed",e)}))}(e,0,n),x(n)}}function I(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function x(e){if(I())return _(e,"chromecast:available");_(e,"chromecast:unavailable")}const N="is-chromecast-playing";function D(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const o=function(e){var t;const n=e.seekable;return n.length?e.hasState(N)||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),r=t||e.live_state.dvr_window;return{head:o,tail:"number"!=typeof r||o-r<0?n.start(0):o-r}}function M(e){const t=e.currentTime,n=D(e);return{progress:Math.min(100,Math.max(0,(t-n.tail)/(n.head-n.tail)*100)),is_live:t-n.head>=-10}}const j={player:void 0,listener:void 0};function F(e,t,n,o){var a,s,i,c,p;const f=l();if(!f)return;const v=u(e);if(!v||!v.src)return;w.casting_player=e;const h=new chrome.cast.media.MediaInfo(v.src,v.type||"");h.metadata=new chrome.cast.media.GenericMediaMetadata,function(e){j.player&&j.listener&&j.player.off("playing",j.listener);const t={currentTime:e.currentSessionTime,liveState:e.live_state,progress:M(e).progress};j.player=e,j.listener=()=>{setTimeout(()=>{!function(e,t){const n=m();if(!n)return;if(-1!==n.media.duration)return e.currentTime=t.currentTime;const o=n.liveSeekableRange;if(!o||"number"!=typeof o.end||"number"!=typeof o.start)return;if(void 0===t.liveState.dvr_window||!t.liveState.dvr)return;e.currentTime=(o.end-o.start)*(t.progress/100)}(e,t)},1e3)},e.once("playing",j.listener)}(e);const g={health:e.health,text_tracks:A(e),active_tracks:{active_audio:(null===(s=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===s?void 0:s.name)||(null===(c=null===(i=null==e?void 0:e.asel)||void 0===i?void 0:i.active_track)||void 0===c?void 0:c.lang),active_text:null===(p=T(e).find(e=>e.is_active))||void 0===p?void 0:p.label}};v.drm&&(g.drm=v.drm),localStorage.__fpChromecastDebug&&(g.debug=!0),e.opt("ads")&&(g.ads=e.opt("ads")),h.customData=g,d(e,h);const y=new chrome.cast.media.LoadRequest(h);y.customData=e.opt("chromecast",{}),y.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:y}),console.debug("cast:request(%o)",y),f.loadMedia(y).then(()=>{e.emit("remotesession:started"),e.setState("has-casted",!0),e.setState("is-casting",!0),E(t);const n=w.remote_player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),S(t,r)},o)}function R(){return!!m()}function G(){return!!l()}function q(){var e;return null===(e=l())||void 0===e?void 0:e.getCastDevice().friendlyName}function H(){var e;return(null===(e=null==k?void 0:l())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function V(){var e,t;return null===(t=null===(e=m())||void 0===e?void 0:e.media)||void 0===t?void 0:t.duration}function U(){var e;return null===(e=m())||void 0===e?void 0:e.playerState}function B(e){var t;return e?z(e):null===(t=m())||void 0===t?void 0:t.getEstimatedTime()}function z(e){const t=m();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function Y(){var e;return null===(e=m())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function J(){var e;return null===(e=m())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var X=Object.freeze({__proto__:null,load:F,has_media:R,exists:G,device_name:q,seekable_ranges:H,duration:V,state:U,currentTime:B,seek:z,play:Y,pause:J});function $(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let o="";o=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),o=o.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=o}const Q="currentTime",K="duration",W="playerState",Z="videoInfo",ee="volumeLevel",te="isMuted",ne="liveSeekableRange",oe=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=l();if(n)return n.endSession(!0);e.emit("chromecast:start"),t.target===this&&this.cast_launcher.click()}),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function re(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,o;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",o=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,o),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");P(e,0,this.flowplayer.instances),n.on("mount",(function(){const t=re(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const o=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(o),e.prepend(n)}(t,{poster:e.poster});const o=re(n,"flowplayer-header-right-zone");o&&o.prepend(oe(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),function(e,t){const n={play:function(){return new Promise(n=>p(e)?n(Y()):R()?n(F(e,t,console.debug,console.error)):(F(e,t,console.debug,console.error),void n()))},pause:function(){return p(e)?J():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:B,set:B},n.seekable={get:()=>{const e=H();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:V},n.paused={get:function(){return"PAUSED"===U()}},n.playing={get:function(){return"PLAYING"===U()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var o,r;return p(e)?n[t].get():null===(r=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.get)||void 0===r?void 0:r.call(this)},set:function(o){var r,a;return p(e)?n[t].set(o):null===(a=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.set)||void 0===a?void 0:a.call(this,o)}});const o=e[t];e[t]=function(){const r=[].slice.apply(arguments);return G()?n[t].apply(e,r):o.apply(e,r)}}))}(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1)})),n.on("chromecast:start",()=>{if(w.casting_player=n,this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),R())return F(n,this.flowplayer.instances,console.debug,console.error)}),n.on("volumechange",()=>{const e=w.remote_player,t=w.controller;if(!R()||!e||!t)return;const o=n.volume,r=n.muted;o!==e.volumeLevel&&(e.volumeLevel=o,t.setVolumeLevel()),r!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",(function(e){var t,o,r;if(R())return e.data?void C((null===(r=null===(o=null===(t=m())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=T(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):C([])})),n.on("audio:update",()=>{R()&&setTimeout(()=>{var e,t,o,r,a;const s=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,i=null===(a=null===(r=null===(o=null===(t=m())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==s?void 0:s.name):e.language===(null==s?void 0:s.lang)))||void 0===a?void 0:a.trackId;"number"==typeof i&&C([i])},0)}),n.on(r,()=>{if(n.setState("is-starting",!0),!n.hasState("is-casting"))return;const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended")),n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n)}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:o}=e.data;switch(t){case K:return void(-1!==o||n.opts.live||n.setOpts({live:!0}));case te:return n.muted=o;case ee:return n.volume=o;case ne:return n.emit("dvr/window",o.end-o.start);case Q:return Math.abs(o-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=o,n.emit("timeupdate",o);case W:return"PLAYING"==o?n.emit("playing"):"PAUSED"==o?n.emit("pause"):void 0;case Z:var r=(o||{}).fake_session||X;return $(n,{device:r.device_name(),state:r.state()}),r.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState(N,!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:if(!n.hasState("is-casting"))return;return w.casting_player=void 0,n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:if(!p(n))return;return w.casting_player=n,n.setState(n.paused?"is-paused":"is-playing",!0),n.setState("is-casting",!0),n.setState("has-casted",!0),n.setState(N,!0),n.emit("timeupdate"),n.currentSessionTime=n.currentTime,$(n,{device:q(),state:U()}),n.setState("is-starting",!1);case cast.framework.SessionState.SESSION_STARTED:if(n!==w.casting_player)return;F(n,this.flowplayer.instances,console.debug,console.error)}})}reset_state(e){e.setState(N,!1),e.setState("is-casting",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}ChromecastPlugin.pluginName="chromecast",ChromecastPlugin.apps=O,ChromecastPlugin.events=a,ChromecastPlugin.hlsSegmentFormat={audio:s,video:i};return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const 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,ChromecastPlugin)}));
@@ -3,8 +3,6 @@
3
3
  import type { BitrateInfo } from 'dashjs';
4
4
  import type { Get } from 'type-fest';
5
5
  import type { Level } from 'hls.js';
6
- import type { MediaKeyFunc } from 'hls.js';
7
- import type { SetFieldType } from 'type-fest';
8
6
  import type { TupleToUnion } from 'type-fest';
9
7
 
10
8
  /* Excluded from this release type: AnyLoader */
@@ -268,41 +266,6 @@ declare const DESTROYED = "is-destroyed";
268
266
 
269
267
  declare const DISABLED = "is-disabled";
270
268
 
271
- /**
272
- * @public
273
- */
274
- declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
275
-
276
- /**
277
- * @public
278
- */
279
- declare type DRMConfiguration = {
280
- license_server: string;
281
- http_headers?: Record<string, string>;
282
- certificate?: string;
283
- vendor?: string | DRMVendorImplementation;
284
- request_media_key_system_access_function?: MediaKeyFunc;
285
- query_params?: Record<string, string>;
286
- };
287
-
288
- /**
289
- * @public
290
- */
291
- declare type DRMSourceConfiguration = {
292
- [keysystem in DRM_KEYSYSTEM]?: DRMConfiguration;
293
- };
294
-
295
- /**
296
- * @public
297
- */
298
- declare type DRMVendorImplementation = {
299
- fairplay_fetch_certificate: (url: string, cb: (certificate_data: Uint8Array) => void) => void;
300
- fairplay_request_license: (url: string, params: {
301
- message: any;
302
- assetId: string;
303
- }, cb: (license_data: Uint8Array) => void) => void;
304
- };
305
-
306
269
  /**
307
270
  * @public
308
271
  */
@@ -529,13 +492,13 @@ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Co
529
492
  * @param selector - query selector of the HTML element where player will render
530
493
  * @param config - Configuration of the flowplayer and the attached plugins
531
494
  */
532
- (selector: string, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
495
+ (selector: string, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
533
496
  /**
534
497
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
535
498
  * @param element - HTML element where player will render
536
499
  * @param config - Configuration of the flowplayer and the attached plugins
537
500
  */
538
- (element: HTMLElement, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
501
+ (element: HTMLElement, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
539
502
  }
540
503
 
541
504
  /**
@@ -1152,6 +1115,11 @@ declare type PlayerState = FlowplayerStates[keyof FlowplayerStates];
1152
1115
  */
1153
1116
  declare type PlayerWith<T> = T & Player;
1154
1117
 
1118
+ declare type PlayerWithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = Omit<PluginPlayer, "opts" | "setOpts"> & {
1119
+ opts: PluginConfig;
1120
+ setOpts: (config: PluginConfig) => void;
1121
+ };
1122
+
1155
1123
  declare const PLAYING = "is-playing";
1156
1124
 
1157
1125
  /**
@@ -1182,6 +1150,7 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer ex
1182
1150
  */
1183
1151
  declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1184
1152
  new (umd: FlowplayerUMD, player: Player): Plugin_2<PluginConfig, PluginPlayer>;
1153
+ pluginName: string;
1185
1154
  }
1186
1155
 
1187
1156
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -1480,7 +1449,6 @@ declare type SourceObj<T = unknown> = {
1480
1449
  * the MIME type (example `video/mp4` or `application/x-mpegurl`)
1481
1450
  */
1482
1451
  type?: string;
1483
- drm?: DRMSourceConfiguration;
1484
1452
  } & T;
1485
1453
 
1486
1454
  /**
@@ -1704,6 +1672,4 @@ declare const WILL_PLAY = "will-play";
1704
1672
 
1705
1673
  declare const WILL_SEEK = "will-seek";
1706
1674
 
1707
- declare type WithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = SetFieldType<SetFieldType<PluginPlayer, "opts", PluginConfig>, "setOpts", (config: PluginConfig) => void>;
1708
-
1709
1675
  export { }
@@ -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.comscore=e())}(this,(function(){"use strict";function t(){return"undefined"!=typeof ns_}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 s=t.flowplayer;return"function"==typeof s?(s(e),e):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(e)||s.extensions.push(e),e)}(window,class ComscorePlugin{constructor(){this.started=!1,this.paused=!1,this.ad_playing=!1,this.title="",this.id="",this.account_id="",this.is_live=!1,this.content_duration=0}init(e,s,i){if("object"!=typeof e.comscore)return;if(i.hasState("consent-no-tracking"))return;if(this.video=i,this.config=e,t())return this.wireup();const n=document.createElement("script");n.src="https://sb.scorecardresearch.com/c2/libraries/js/v6/6.3.1.181004.js",n.onload=()=>this.wireup(),document.body.appendChild(n)}wireup(){if(t()&&this.video){if(document){document.addEventListener("unload",this.closed),document.addEventListener("pagehide",this.closed2);const t=this.getHiddenProp();if(t){const e=t.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(e,this.visChange)}}var e;this.video.on(["loadedmetadata","loadeddata","progress","loadstart","ended","seeked","seeking","pause","playing","load","config","ad-started","ad-completed","ad-break-completed"],(e=t=>{switch(t.type){case"playing":this.playing();break;case"pause":this.pause();break;case"seeking":this.seeking();break;case"seeked":this.seeked();break;case"ended":this.ended();break;case"config":this.configured(t);break;case"ad-started":this.ad_started(t);break;case"ad-completed":this.ad_completed();break;case"ad-break-completed":this.ad_break_completed()}},t=>{setTimeout((function(){if(!t.defaultPrevented)return e(t)}),0)}))}}playing(){this.streamingAnalytics||(this.streamingAnalytics=this.setupStreamingAnalytics()),this.started?this.paused&&this.setContentClip():(this.started=!0,this.setContentClip()),this.paused=!1}pause(){this.streamingAnalytics&&!this.ad_playing&&(this.paused=!0,this.streamingAnalytics.stop())}ended(){this.ad_playing=!1,this.started=!1,this.paused=!1,this.content_duration=0,this.streamingAnalytics&&(this.streamingAnalytics.stop(),this.interval=setInterval(()=>this.killStreamingAnalytics,1e3))}killStreamingAnalytics(){this.interval&&clearInterval(this.interval),this.streamingAnalytics&&(this.streamingAnalytics=null)}seeking(){}seeked(){}closed2(){this.ended()}closed(){this.ended()}visChange(){this.streamingAnalytics&&(this.isHidden()?this.streamingAnalytics.stop():this.setContentClip())}getHiddenProp(){const t=["webkit","moz","ms","o"];return"hidden"in document?"hidden":(Array.from({length:t.length}).map((t,e)=>e).forEach(e=>{if(t[e]+"Hidden"in document)return t[e]+"Hidden"}),null)}isHidden(){const t=this.getHiddenProp();return!!t&&document[t]}configured(t){!this.comscore_object&&this.config&&(this.comscore_object=this.config.comscore,this.title=this.comscore_object.media_title||"*null",this.id=this.comscore_object.media_id||"*null",this.account_id=this.comscore_object.account_id,this.streamingAnalytics=this.setupStreamingAnalytics(),t.data&&(t.data.live&&(this.is_live=!0),t.data.title&&(this.title=t.data.title),t.data.metadata&&t.data.metadata.media_id&&(this.id=t.data.metadata.media_id),t.data.duration&&(this.content_duration=Math.round(1e3*t.data.duration))))}ad_started(t){this.setAdvertisementClip(t)}ad_completed(){this.streamingAnalytics&&this.streamingAnalytics.stop()}ad_break_completed(){this.setContentClip()}setAdvertisementClip(t){var e;if(this.ad_playing=!0,null==this.comscore_object&&(this.comscore_object=null===(e=this.config)||void 0===e?void 0:e.comscore),!this.comscore_object)return;const s={};t&&t.data&&t.data.ad?s.ns_st_cl=Math.round(1e3*t.data.ad.duration)||0:s.ns_st_cl=0,s.c3=this.comscore_object.c3||"*null",s.c4=this.comscore_object.c4||"*null",s.c6=this.comscore_object.c6||"*null",this.streamingAnalytics&&(this.is_live?this.streamingAnalytics.playVideoAdvertisement(s,ns_.ReducedRequirementsStreamingAnalytics.AdType.LinearLive):this.streamingAnalytics.playVideoAdvertisement(s,ns_.ReducedRequirementsStreamingAnalytics.AdType.LinearOnDemandPreRoll))}setContentClip(){var t;this.ad_playing=!1;const e={};null==this.comscore_object&&(this.comscore_object=null===(t=this.config)||void 0===t?void 0:t.comscore),this.comscore_object&&this.video&&(e.ns_st_ci=this.id,e.ns_st_pr=this.title,e.ns_st_ep=this.comscore_object.ns_st_ep||"*null",e.ns_st_ia=this.comscore_object.ns_st_ia||0,e.ns_st_ge=this.comscore_object.ns_st_ge||"News",e.ns_st_ce=this.comscore_object.ns_st_ce||0,e.ns_st_ddt=this.comscore_object.ns_st_ddt||(new Date).getFullYear()+"-01-01",e.ns_st_tdt=this.comscore_object.ns_st_tdt||(new Date).getFullYear()+"-01-01",e.c3=this.comscore_object.c3||"*null",e.c4=this.comscore_object.c4||"*null",e.c6=this.comscore_object.c6||"*null",this.content_duration<=0&&(this.content_duration=Math.round(1e3*this.video.duration)),e.ns_st_cl=this.content_duration,this.streamingAnalytics&&(this.is_live?(e.ns_st_cl=0,this.streamingAnalytics.playVideoContentPart(e,ns_.ReducedRequirementsStreamingAnalytics.ContentType.Live)):this.streamingAnalytics.playVideoContentPart(e,ns_.ReducedRequirementsStreamingAnalytics.ContentType.ShortFormOnDemand)))}setupStreamingAnalytics(){return new ns_.ReducedRequirementsStreamingAnalytics({publisherId:this.account_id})}})}));
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.comscore=e())}(this,(function(){"use strict";var t;function e(){return"undefined"!=typeof ns_}const s=((t=class ComscorePlugin{constructor(){this.started=!1,this.paused=!1,this.ad_playing=!1,this.title="",this.id="",this.account_id="",this.is_live=!1,this.content_duration=0}init(t,s,i){if("object"!=typeof t.comscore)return;if(i.hasState("consent-no-tracking"))return;if(this.video=i,this.config=t,e())return this.wireup();const n=document.createElement("script");n.src="https://sb.scorecardresearch.com/c2/libraries/js/v6/6.3.1.181004.js",n.onload=()=>this.wireup(),document.body.appendChild(n)}wireup(){if(e()&&this.video){if(document){document.addEventListener("unload",this.closed),document.addEventListener("pagehide",this.closed2);const t=this.getHiddenProp();if(t){const e=t.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(e,this.visChange)}}var t;this.video.on(["loadedmetadata","loadeddata","progress","loadstart","ended","seeked","seeking","pause","playing","load","config","ad-started","ad-completed","ad-break-completed"],(t=t=>{switch(t.type){case"playing":this.playing();break;case"pause":this.pause();break;case"seeking":this.seeking();break;case"seeked":this.seeked();break;case"ended":this.ended();break;case"config":this.configured(t);break;case"ad-started":this.ad_started(t);break;case"ad-completed":this.ad_completed();break;case"ad-break-completed":this.ad_break_completed()}},e=>{setTimeout((function(){if(!e.defaultPrevented)return t(e)}),0)}))}}playing(){this.streamingAnalytics||(this.streamingAnalytics=this.setupStreamingAnalytics()),this.started?this.paused&&this.setContentClip():(this.started=!0,this.setContentClip()),this.paused=!1}pause(){this.streamingAnalytics&&!this.ad_playing&&(this.paused=!0,this.streamingAnalytics.stop())}ended(){this.ad_playing=!1,this.started=!1,this.paused=!1,this.content_duration=0,this.streamingAnalytics&&(this.streamingAnalytics.stop(),this.interval=setInterval(()=>this.killStreamingAnalytics,1e3))}killStreamingAnalytics(){this.interval&&clearInterval(this.interval),this.streamingAnalytics&&(this.streamingAnalytics=null)}seeking(){}seeked(){}closed2(){this.ended()}closed(){this.ended()}visChange(){this.streamingAnalytics&&(this.isHidden()?this.streamingAnalytics.stop():this.setContentClip())}getHiddenProp(){const t=["webkit","moz","ms","o"];return"hidden"in document?"hidden":(Array.from({length:t.length}).map((t,e)=>e).forEach(e=>{if(t[e]+"Hidden"in document)return t[e]+"Hidden"}),null)}isHidden(){const t=this.getHiddenProp();return!!t&&document[t]}configured(t){!this.comscore_object&&this.config&&(this.comscore_object=this.config.comscore,this.title=this.comscore_object.media_title||"*null",this.id=this.comscore_object.media_id||"*null",this.account_id=this.comscore_object.account_id,this.streamingAnalytics=this.setupStreamingAnalytics(),t.data&&(t.data.live&&(this.is_live=!0),t.data.title&&(this.title=t.data.title),t.data.metadata&&t.data.metadata.media_id&&(this.id=t.data.metadata.media_id),t.data.duration&&(this.content_duration=Math.round(1e3*t.data.duration))))}ad_started(t){this.setAdvertisementClip(t)}ad_completed(){this.streamingAnalytics&&this.streamingAnalytics.stop()}ad_break_completed(){this.setContentClip()}setAdvertisementClip(t){var e;if(this.ad_playing=!0,null==this.comscore_object&&(this.comscore_object=null===(e=this.config)||void 0===e?void 0:e.comscore),!this.comscore_object)return;const s={};t&&t.data&&t.data.ad?s.ns_st_cl=Math.round(1e3*t.data.ad.duration)||0:s.ns_st_cl=0,s.c3=this.comscore_object.c3||"*null",s.c4=this.comscore_object.c4||"*null",s.c6=this.comscore_object.c6||"*null",this.streamingAnalytics&&(this.is_live?this.streamingAnalytics.playVideoAdvertisement(s,ns_.ReducedRequirementsStreamingAnalytics.AdType.LinearLive):this.streamingAnalytics.playVideoAdvertisement(s,ns_.ReducedRequirementsStreamingAnalytics.AdType.LinearOnDemandPreRoll))}setContentClip(){var t;this.ad_playing=!1;const e={};null==this.comscore_object&&(this.comscore_object=null===(t=this.config)||void 0===t?void 0:t.comscore),this.comscore_object&&this.video&&(e.ns_st_ci=this.id,e.ns_st_pr=this.title,e.ns_st_ep=this.comscore_object.ns_st_ep||"*null",e.ns_st_ia=this.comscore_object.ns_st_ia||0,e.ns_st_ge=this.comscore_object.ns_st_ge||"News",e.ns_st_ce=this.comscore_object.ns_st_ce||0,e.ns_st_ddt=this.comscore_object.ns_st_ddt||(new Date).getFullYear()+"-01-01",e.ns_st_tdt=this.comscore_object.ns_st_tdt||(new Date).getFullYear()+"-01-01",e.c3=this.comscore_object.c3||"*null",e.c4=this.comscore_object.c4||"*null",e.c6=this.comscore_object.c6||"*null",this.content_duration<=0&&(this.content_duration=Math.round(1e3*this.video.duration)),e.ns_st_cl=this.content_duration,this.streamingAnalytics&&(this.is_live?(e.ns_st_cl=0,this.streamingAnalytics.playVideoContentPart(e,ns_.ReducedRequirementsStreamingAnalytics.ContentType.Live)):this.streamingAnalytics.playVideoContentPart(e,ns_.ReducedRequirementsStreamingAnalytics.ContentType.ShortFormOnDemand)))}setupStreamingAnalytics(){return new ns_.ReducedRequirementsStreamingAnalytics({publisherId:this.account_id})}}).pluginName="comscore",t);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 s=t.flowplayer;return"function"==typeof s?(s(e),e):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(e)||s.extensions.push(e),e)}(window,s)}));
@@ -3,8 +3,6 @@
3
3
  import type { BitrateInfo } from 'dashjs';
4
4
  import type { Get } from 'type-fest';
5
5
  import type { Level } from 'hls.js';
6
- import type { MediaKeyFunc } from 'hls.js';
7
- import type { SetFieldType } from 'type-fest';
8
6
  import type { TupleToUnion } from 'type-fest';
9
7
 
10
8
  /* Excluded from this release type: AnyLoader */
@@ -294,41 +292,6 @@ declare const DESTROYED = "is-destroyed";
294
292
 
295
293
  declare const DISABLED = "is-disabled";
296
294
 
297
- /**
298
- * @public
299
- */
300
- declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
301
-
302
- /**
303
- * @public
304
- */
305
- declare type DRMConfiguration = {
306
- license_server: string;
307
- http_headers?: Record<string, string>;
308
- certificate?: string;
309
- vendor?: string | DRMVendorImplementation;
310
- request_media_key_system_access_function?: MediaKeyFunc;
311
- query_params?: Record<string, string>;
312
- };
313
-
314
- /**
315
- * @public
316
- */
317
- declare type DRMSourceConfiguration = {
318
- [keysystem in DRM_KEYSYSTEM]?: DRMConfiguration;
319
- };
320
-
321
- /**
322
- * @public
323
- */
324
- declare type DRMVendorImplementation = {
325
- fairplay_fetch_certificate: (url: string, cb: (certificate_data: Uint8Array) => void) => void;
326
- fairplay_request_license: (url: string, params: {
327
- message: any;
328
- assetId: string;
329
- }, cb: (license_data: Uint8Array) => void) => void;
330
- };
331
-
332
295
  /**
333
296
  * @public
334
297
  */
@@ -555,13 +518,13 @@ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Co
555
518
  * @param selector - query selector of the HTML element where player will render
556
519
  * @param config - Configuration of the flowplayer and the attached plugins
557
520
  */
558
- (selector: string, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
521
+ (selector: string, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
559
522
  /**
560
523
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
561
524
  * @param element - HTML element where player will render
562
525
  * @param config - Configuration of the flowplayer and the attached plugins
563
526
  */
564
- (element: HTMLElement, config?: ConfigWithPlugins): WithOpts<PluginPlayer, ConfigWithPlugins>;
527
+ (element: HTMLElement, config?: ConfigWithPlugins): PlayerWithOpts<PluginPlayer, ConfigWithPlugins>;
565
528
  }
566
529
 
567
530
  /**
@@ -1178,6 +1141,11 @@ declare type PlayerState = FlowplayerStates[keyof FlowplayerStates];
1178
1141
  */
1179
1142
  declare type PlayerWith<T> = T & Player;
1180
1143
 
1144
+ declare type PlayerWithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = Omit<PluginPlayer, "opts" | "setOpts"> & {
1145
+ opts: PluginConfig;
1146
+ setOpts: (config: PluginConfig) => void;
1147
+ };
1148
+
1181
1149
  declare const PLAYING = "is-playing";
1182
1150
 
1183
1151
  /**
@@ -1208,6 +1176,7 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer ex
1208
1176
  */
1209
1177
  declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1210
1178
  new (umd: FlowplayerUMD, player: Player): Plugin_2<PluginConfig, PluginPlayer>;
1179
+ pluginName: string;
1211
1180
  }
1212
1181
 
1213
1182
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -1506,7 +1475,6 @@ declare type SourceObj<T = unknown> = {
1506
1475
  * the MIME type (example `video/mp4` or `application/x-mpegurl`)
1507
1476
  */
1508
1477
  type?: string;
1509
- drm?: DRMSourceConfiguration;
1510
1478
  } & T;
1511
1479
 
1512
1480
  /**
@@ -1752,6 +1720,4 @@ declare const WILL_PLAY = "will-play";
1752
1720
 
1753
1721
  declare const WILL_SEEK = "will-seek";
1754
1722
 
1755
- declare type WithOpts<PluginPlayer extends Player = Player, PluginConfig extends Config = Config> = SetFieldType<SetFieldType<PluginPlayer, "opts", PluginConfig>, "setOpts", (config: PluginConfig) => void>;
1756
-
1757
1723
  export { }
@@ -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.consent=e())}(this,(function(){"use strict";class PlayerStorage{constructor(t,e){this.implementation=t,e&&e.keys().forEach(t=>{"string"==typeof e.implementation[t]&&this.implementation.setItem(t,e.implementation[t])})}keys(){var t;const e=[];for(var n=0;n<this.implementation.length;n++)(null===(t=this.implementation.key(n))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(n));return e}removeItem(t){try{this.implementation.removeItem("flowplayer/"+t)}catch(t){}}getItem(t){try{return this.implementation.getItem("flowplayer/"+t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem("flowplayer/"+t,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}var t,e,n;!function(t){t[t.ALL=1]="ALL",t[t.NONE=2]="NONE"}(t||(t={})),function(t){t[t.ALL=8]="ALL",t[t.NONE=16]="NONE"}(e||(e={}));const s=((n=class ConsentPlugin{constructor(n,s){const o=s._storage.getItem("consent"),r=this.current_value=o&&!isNaN(Number(o))?Number(s._storage.getItem("consent")):t.NONE|e.NONE;this.player=s,this.adapt(Object.assign({consent:r},s.opts))}init(t,e,n){this.adapt(t),n.on("config",t=>{this.adapt(t.detail)});const s=t=>{n.setOpts({consent:t.detail})};document.addEventListener("flowplayer/consent",s),n.on("reap",()=>document.removeEventListener("flowplayer/consent",s))}adapt(n){const s=void 0===n.consent?this.current_value:n.consent;e.ALL&s?this.setStorage(e.ALL):e.NONE&s&&this.setStorage(e.NONE),t.ALL&s?this.setTracking(t.ALL):t.NONE&s&&this.setTracking(t.NONE),this.player._storage.setItem("consent",s.toString())}setStorage(t){try{const n=this.player._storage;switch(this.player.setState("consent-no-storage",t===e.NONE),t){case e.ALL:this.player._storage=new PlayerStorage(localStorage,this.player._storage);break;case e.NONE:this.player._storage=new PlayerStorage(sessionStorage,n),n.clear()}}catch(t){console.debug(t)}}setTracking(e){var n,s;switch(this.player.setState("consent-no-tracking",e===t.NONE),e){case t.ALL:null===(n=this.player.health)||void 0===n||n.toggle(!0);break;case t.NONE:null===(s=this.player.health)||void 0===s||s.toggle(!1)}}}).tracking=t,n.storage=e,n);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,s)}));
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.consent=e())}(this,(function(){"use strict";class PlayerStorage{constructor(t,e){this.implementation=t,e&&e.keys().forEach(t=>{"string"==typeof e.implementation[t]&&this.implementation.setItem(t,e.implementation[t])})}keys(){var t;const e=[];for(var n=0;n<this.implementation.length;n++)(null===(t=this.implementation.key(n))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(n));return e}removeItem(t){try{this.implementation.removeItem("flowplayer/"+t)}catch(t){}}getItem(t){try{return this.implementation.getItem("flowplayer/"+t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem("flowplayer/"+t,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}var t,e,n;!function(t){t[t.ALL=1]="ALL",t[t.NONE=2]="NONE"}(t||(t={})),function(t){t[t.ALL=8]="ALL",t[t.NONE=16]="NONE"}(e||(e={}));const s=((n=class ConsentPlugin{constructor(n,s){const o=s._storage.getItem("consent"),r=this.current_value=o&&!isNaN(Number(o))?Number(s._storage.getItem("consent")):t.NONE|e.NONE;this.player=s,this.adapt(Object.assign({consent:r},s.opts))}init(t,e,n){this.adapt(t),n.on("config",t=>{this.adapt(t.detail)});const s=t=>{n.setOpts({consent:t.detail})};document.addEventListener("flowplayer/consent",s),n.on("reap",()=>document.removeEventListener("flowplayer/consent",s))}adapt(n){const s=void 0===n.consent?this.current_value:n.consent;e.ALL&s?this.setStorage(e.ALL):e.NONE&s&&this.setStorage(e.NONE),t.ALL&s?this.setTracking(t.ALL):t.NONE&s&&this.setTracking(t.NONE),this.player._storage.setItem("consent",s.toString())}setStorage(t){try{const n=this.player._storage;switch(this.player.setState("consent-no-storage",t===e.NONE),t){case e.ALL:this.player._storage=new PlayerStorage(localStorage,this.player._storage);break;case e.NONE:this.player._storage=new PlayerStorage(sessionStorage,n),n.clear()}}catch(t){console.debug(t)}}setTracking(e){var n,s;switch(this.player.setState("consent-no-tracking",e===t.NONE),e){case t.ALL:null===(n=this.player.health)||void 0===n||n.toggle(!0);break;case t.NONE:null===(s=this.player.health)||void 0===s||s.toggle(!1)}}}).pluginName="consent",n.tracking=t,n.storage=e,n);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,s)}));