@flowplayer/player 3.15.1-rc → 3.16.0-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/core/events.d.ts +22 -2
  2. package/core/events.js +50 -50
  3. package/core.js +1 -1
  4. package/default.js +1 -1
  5. package/embed.js +2 -2
  6. package/flowplayer.css +1 -1
  7. package/index.d.ts +78 -35
  8. package/package.json +1 -1
  9. package/plugins/ads.d.ts +76 -33
  10. package/plugins/ads.js +1 -1
  11. package/plugins/airplay.d.ts +76 -33
  12. package/plugins/analytics.d.ts +76 -33
  13. package/plugins/analytics.js +1 -1
  14. package/plugins/asel.d.ts +221 -36
  15. package/plugins/asel.js +1 -1
  16. package/plugins/audio.d.ts +76 -33
  17. package/plugins/chapters.d.ts +76 -33
  18. package/plugins/chromecast.d.ts +76 -33
  19. package/plugins/chromecast.js +1 -1
  20. package/plugins/comscore.d.ts +76 -33
  21. package/plugins/consent.d.ts +76 -33
  22. package/plugins/context-menu.d.ts +76 -33
  23. package/plugins/cuepoints.d.ts +76 -33
  24. package/plugins/dash.d.ts +76 -33
  25. package/plugins/dash.js +1 -1
  26. package/plugins/drm.d.ts +76 -33
  27. package/plugins/endscreen.d.ts +76 -33
  28. package/plugins/fas.d.ts +76 -33
  29. package/plugins/float-on-scroll.d.ts +76 -33
  30. package/plugins/ga4.d.ts +76 -33
  31. package/plugins/gemius.d.ts +76 -33
  32. package/plugins/google-analytics.d.ts +76 -33
  33. package/plugins/health.d.ts +76 -33
  34. package/plugins/health.js +1 -1
  35. package/plugins/hls.d.ts +76 -33
  36. package/plugins/hls.js +1 -1
  37. package/plugins/id3.d.ts +76 -33
  38. package/plugins/iframe.d.ts +76 -33
  39. package/plugins/keyboard.d.ts +76 -33
  40. package/plugins/media-session.d.ts +76 -33
  41. package/plugins/message.d.ts +76 -33
  42. package/plugins/ovp.d.ts +76 -33
  43. package/plugins/playlist.d.ts +107 -33
  44. package/plugins/playlist.js +1 -1
  45. package/plugins/preview.d.ts +76 -33
  46. package/plugins/qsel.d.ts +76 -33
  47. package/plugins/qul.d.ts +76 -33
  48. package/plugins/rts.d.ts +76 -33
  49. package/plugins/share.d.ts +76 -33
  50. package/plugins/speed.d.ts +76 -33
  51. package/plugins/ssai.d.ts +76 -33
  52. package/plugins/ssai.js +1 -1
  53. package/plugins/subtitles.d.ts +76 -33
  54. package/plugins/thumbnails.d.ts +76 -33
  55. package/plugins/tizen.d.ts +76 -33
  56. package/plugins/vtsel.d.ts +76 -33
  57. package/plugins/webos.d.ts +76 -33
  58. package/util/loader.d.ts +76 -33
@@ -344,6 +344,7 @@ declare type ErrorEventDetail = {
344
344
  declare namespace events {
345
345
  export {
346
346
  MOUNT,
347
+ RETRY,
347
348
  ERROR,
348
349
  CONTEXT_MENU,
349
350
  CLICK,
@@ -395,7 +396,8 @@ declare namespace events {
395
396
  LANDSCAPE,
396
397
  PORTRAIT,
397
398
  DVR,
398
- LIVE_2 as LIVE
399
+ LIVE,
400
+ RECOVER
399
401
  }
400
402
  }
401
403
 
@@ -594,8 +596,6 @@ declare const /**
594
596
  */
595
597
  LANDSCAPE = "landscape";
596
598
 
597
- declare const LIVE = "is-live";
598
-
599
599
  /**
600
600
  * @public
601
601
  * when src is a livestream
@@ -607,7 +607,9 @@ declare const /**
607
607
  * @public
608
608
  * when src is a livestream
609
609
  */
610
- LIVE_2 = "live";
610
+ LIVE = "live";
611
+
612
+ declare const LIVE_2 = "is-live";
611
613
 
612
614
  declare const LIVE_SEEKED = "is-live-seeked";
613
615
 
@@ -907,33 +909,27 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
907
909
 
908
910
  declare type PlayerCustomEventName = keyof PlayerCustomEventsDetailMap;
909
911
 
910
- declare type PlayerCustomEventsDetailMap = {
911
- [MOUNT]: MountEventDetail;
912
- [ERROR]: ErrorEventDetail;
913
- [CONTEXT_MENU]: ContextMenuEventDetail;
914
- /* Excluded from this release type: beforeplay */
915
- /* Excluded from this release type: beforepause */
916
- /* Excluded from this release type: state */
912
+ declare type PlayerCustomEventsDetailMap = PlayerEmittableCustomEventsDetailMap & {
913
+ [REAP]: ReapEventDetail;
914
+ [SOURCE]: SourceEventDetail;
917
915
  [CUEPOINT_START]: CuePointStartEventDetail;
918
916
  [CUEPOINT_END]: CuePointEndEventDetail;
919
- [VIEW_ENTER]: ViewEnterEventDetail;
920
- [VIEW_LEAVE]: ViewLeaveEventDetail;
921
- [SOURCE]: SourceEventDetail;
922
- /* Excluded from this release type: recover */
923
- [REAP]: ReapEventDetail;
924
- /* Excluded from this release type: config */
925
- [QUALITIES]: QualitiesEventDetail;
926
- /* Excluded from this release type: "error:fatal" */
927
- [RECOMMENDATIONS_READY]: RecommendationsReadyEventDetail;
917
+ [MOUNT]: MountEventDetail;
918
+ [LIVE]: LiveEventDetail;
919
+ [DVR]: DvrEventDetail;
920
+ [RETRY]: RetryEventDetail;
921
+ [RECOVER]: RecoverEventDetail;
928
922
  /* Excluded from this release type: audioonlysource */
929
923
  /* Excluded from this release type: renderplugin */
930
- [DVR]: DvrEventDetail;
931
- [LIVE_2]: LiveEventDetail;
932
924
  /* Excluded from this release type: "seek:queued" */
933
925
  /* Excluded from this release type: "seek:cancel" */
934
926
  /* Excluded from this release type: "plugin:registered" */
935
927
  /* Excluded from this release type: intersectionchange */
936
- /* Excluded from this release type: retry */
928
+ /* Excluded from this release type: beforeplay */
929
+ /* Excluded from this release type: beforepause */
930
+ /* Excluded from this release type: state */
931
+ /* Excluded from this release type: config */
932
+ /* Excluded from this release type: "error:fatal" */
937
933
  };
938
934
 
939
935
  declare type PlayerCustomEventsOverloads = {
@@ -972,11 +968,18 @@ declare type PlayerCustomEventsOverloads = {
972
968
  * Sent right before the player src attribute is set. This allows you to change the video URL before playback.
973
969
  */
974
970
  on(event: typeof SOURCE, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof SOURCE]>) => void): Player;
975
- /* Excluded from this release type: on */
971
+ /**
972
+ * Emitted when an Error recovery is attempted
973
+ */
974
+ on(event: typeof RECOVER, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof RECOVER]>) => void): Player;
976
975
  /**
977
976
  * Sent when a flowplayer instance is about to be removed from the DOM, and any unsafe references are about to be reaped, which allows Single Page Applications to perform the necessary resource cleanups. This is important when working with front-end frameworks like React. This event should never be emitted directly, only listened to.
978
977
  */
979
978
  on(event: typeof REAP, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof REAP]>) => void): Player;
979
+ /**
980
+ * Emitted when a player will retry to reload
981
+ */
982
+ on(event: typeof RETRY, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof RETRY]>) => void): Player;
980
983
  /* Excluded from this release type: on */
981
984
  /**
982
985
  * Emitted when the set of underlying qualities has changed.
@@ -996,8 +999,7 @@ declare type PlayerCustomEventsOverloads = {
996
999
  /**
997
1000
  * when src is a livestream
998
1001
  */
999
- on(event: typeof LIVE_2, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof LIVE_2]>) => void): Player;
1000
- /* Excluded from this release type: on */
1002
+ on(event: typeof LIVE, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof LIVE]>) => void): Player;
1001
1003
  /* Excluded from this release type: on */
1002
1004
  /* Excluded from this release type: on */
1003
1005
  /* Excluded from this release type: on */
@@ -1026,11 +1028,26 @@ declare type PlayerCustomEventsOverloads = {
1026
1028
  */
1027
1029
  off<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1028
1030
  /* Excluded from this release type: poll */
1029
- emit<T extends PlayerCustomEventName>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1030
1031
  /* Excluded from this release type: emit */
1031
- emit<T, X extends string = string>(event: X & (X extends PlayerCustomEventName ? "Incorrect event detail type" : X), data?: T): Player;
1032
+ /* Excluded from this release type: emit */
1033
+ emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1034
+ /* Excluded from this release type: emit */
1032
1035
  };
1033
1036
 
1037
+ declare type PlayerEmittableCustomEventsDetailMap = {
1038
+ [ERROR]: ErrorEventDetail;
1039
+ [CONTEXT_MENU]: ContextMenuEventDetail;
1040
+ [VIEW_ENTER]: ViewEnterEventDetail;
1041
+ [VIEW_LEAVE]: ViewLeaveEventDetail;
1042
+ [QUALITIES]: QualitiesEventDetail;
1043
+ [RECOMMENDATIONS_READY]: RecommendationsReadyEventDetail;
1044
+ };
1045
+
1046
+ declare type PlayerEmittableEventNames = keyof PlayerEmittableCustomEventsDetailMap;
1047
+
1048
+ /**
1049
+ * @public
1050
+ */
1034
1051
  declare type PlayerEventOverloads = PlayerNativeEventsOverloads & PlayerCustomEventsOverloads;
1035
1052
 
1036
1053
  declare type PlayerNativeEventName = keyof PlayerNativeEventsDetailMap;
@@ -1082,6 +1099,29 @@ PLAYING_2 = "playing";
1082
1099
  declare const Playlist: PluginCtor<Config, Player>;
1083
1100
  export default Playlist;
1084
1101
 
1102
+ declare type PlaylistConfig = {
1103
+ controls?: string | HTMLElement;
1104
+ autoplay?: boolean;
1105
+ loop?: boolean;
1106
+ skip_controls?: boolean;
1107
+ advance?: boolean;
1108
+ start_index?: number;
1109
+ delay?: number;
1110
+ should_play?: boolean;
1111
+ mode?: QueueModes;
1112
+ sort?: (list: QueueMembers, mode: QueueModes) => QueueMembers;
1113
+ plays?: number;
1114
+ shuffle?: boolean;
1115
+ theme?: string;
1116
+ };
1117
+
1118
+ /**
1119
+ * @public
1120
+ */
1121
+ export declare type PlaylistPluginConfig = ConfigWith<{
1122
+ playlist?: PlaylistConfig;
1123
+ }>;
1124
+
1085
1125
  /**
1086
1126
  * @public
1087
1127
  */
@@ -1173,6 +1213,14 @@ declare enum QualityOpts {
1173
1213
  HIGH = 4
1174
1214
  }
1175
1215
 
1216
+ declare type QueueMembers = Array<Config>;
1217
+
1218
+ declare enum QueueModes {
1219
+ SHUFFLE = 1,
1220
+ FIFO = 2,
1221
+ LOOP = 4
1222
+ }
1223
+
1176
1224
  /**
1177
1225
  * @public
1178
1226
  * emitted when it is safe to clean up a fp instance
@@ -1230,9 +1278,23 @@ declare type RecommendationsReadyEventDetail = {
1230
1278
  playlist: RecommendationItem[];
1231
1279
  };
1232
1280
 
1233
- /* Excluded from this release type: RECOVER */
1281
+ /**
1282
+ * @public
1283
+ * emitted when an Error recovery is attempted
1284
+ */
1285
+ declare const /**
1286
+ @public
1287
+ * when a new player is inserted into the HTML
1288
+ */ /**
1289
+ * @public
1290
+ * emitted when an Error recovery is attempted
1291
+ */
1292
+ RECOVER = "recover";
1234
1293
 
1235
- /* Excluded from this release type: RecoverEventDetail */
1294
+ /**
1295
+ * @public
1296
+ */
1297
+ declare type RecoverEventDetail = null;
1236
1298
 
1237
1299
  /* Excluded from this release type: REMOTE_SESSION_ENDED */
1238
1300
 
@@ -1256,9 +1318,21 @@ declare const /**
1256
1318
  */
1257
1319
  RESIZE = "resize";
1258
1320
 
1259
- /* Excluded from this release type: RETRY */
1321
+ /**
1322
+ * @public
1323
+ */
1324
+ declare const /**
1325
+ @public
1326
+ * when a new player is inserted into the HTML
1327
+ */ /**
1328
+ * @public
1329
+ */
1330
+ RETRY = "retry";
1260
1331
 
1261
- /* Excluded from this release type: RetryEventDetail */
1332
+ /**
1333
+ * @public
1334
+ */
1335
+ declare type RetryEventDetail = null;
1262
1336
 
1263
1337
  declare const RTL = "is-rtl";
1264
1338
 
@@ -1393,7 +1467,7 @@ declare namespace states {
1393
1467
  RTL,
1394
1468
  TV,
1395
1469
  ENDED,
1396
- LIVE,
1470
+ LIVE_2 as LIVE,
1397
1471
  ERRORED,
1398
1472
  WAITING,
1399
1473
  AUTOPLAY,
@@ -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.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function b(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function A(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=b(t,"data.queue",b(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;const s=n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx);t.className=s?"is-current":"is-queued",t.setAttribute("aria-current",""+s)})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","pause"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),n.setAttribute("tabindex","0"),n.setAttribute("role","listitem"),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=A("title",t);n&&e.append(n);const i=A("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var w;function x(t,e){var n,i;const s=e.sort||g,o=null!==(n=e.mode)&&void 0!==n?n:w.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function T(t){return t.idx==t.last_idx}function I(t){const e=t.idx+1;return e>t.last_idx?0:e}function _(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}function g(t,e){return(e&w.SHUFFLE)==w.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function S(t){return x(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(w||(w={})),function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const P=["touchstart","touchmove"];function q(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function N(t,e,n,i){Array.isArray(e)?e.forEach(e=>O(t,e,n,i)):O(t,e,n,i)}function O(t,e,n,i){if(s=e,!~P.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function Y(e,n,i){const s=n.idx+n.plays<0;if(!s&&i.delay)return function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue,o=m(e,"flowplayer-playlist-interstitial");if(!o||!s||!n.delay)return;e.root.classList.add("is-interstitial");const l=s.members[I(s)];q(o,t.INTERSTITIAL_NEXT_ITEM,{next:l})}(e,i);C(e,_(n,s,i.start_index),s)}function C(e,n,i){i||(e.preload=n.preload="auto",!e.opts.autoplay&&e.setOpts({autoplay:1})),e.emit("playlist/advance"),"object"==typeof n&&e.setOpts(n),function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!s)return;const o=s.idx,l=s.members[o],r=e.currentSrc;if(l.src&&e.setSrc(l.src),e.emit(t.PLAYLIST_NEXT,{next_index:o}),e.opts.autoplay||n)return;const a=n=>{("canplay"===n.type&&r!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",a),e.removeEventListener(t.PLAYLIST_NEXT,a),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],a)}(e,i)}function k(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,C(e,n.members[t]))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=S(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function F(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),N(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),N(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=b(t,"data.queue",b(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!T(t)||0!=(t.mode&w.LOOP))return t.members[I(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&w.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function D(t,e){if(!e)return;!1!==e.skip_controls&&(t.skip_controls=F(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function R(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?w.SHUFFLE:w.FIFO;return e.loop&&(n|=w.LOOP),x(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function M(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=k(e,o),l&&Y(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?T(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=S(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return Y(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&Y(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking","src"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&q(n,t.INTERSTITIAL_CANCEL)}))}var j;const H=((j=class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:5,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),D(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{var t;e.root.classList.remove("is-interstitial");const n=null===(t=e.playlist)||void 0===t?void 0:t.queue;n&&C(e,_(n,!1))}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),M(i)}onload(e,n,i,s){R(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,j);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,H)}));
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.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function l(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function o(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;l("Config must be an Object",o(t)&&a(t)),l("property `playlist` is required",o(t.playlist)),l("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,l("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),l("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){l("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){o(t[e])&&l(e+" must be a boolean value if present","boolean"==typeof t[e])})),o(t.delay)&&l("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const l=document.createElement("div");l.classList.add("pane","right"),i.append(s,l);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",s.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),o.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),l.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,l=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",l+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function h(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),this.playlistWrapper=document.createElement("ol"),this.className="fp-playlist-controls is-empty",this.header=this.controlsHeader(e),this.append(this.header,this.playlistWrapper),e.on(t.PLAYLIST_READY,t=>{const n=t.detail.queue;n&&(this.list(n,e),this.classList.toggle("is-empty",!n.members.length))}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;const s=n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx);t.classList.toggle("is-current",s),t.setAttribute("aria-current",""+s)})}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.playlistWrapper.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.playlistWrapper.removeChild(e)})}list(t,e){this.playlistWrapper.innerHTML="",t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.playlistWrapper.append(n)})}videoRow(t,e){const n=document.createElement("li");return n.onclick=this.videoRow_onclick.bind(this,n,e),n.setAttribute("tabindex","0"),n.append(this.item(e,t)),n}item(t,e){const n=document.createElement("div");n.className="fp-playlist-controls-item";const i=this.itemHeader(t,e),s=this.itemContent(e);return n.append(i,s),n}itemContent(t){var e,n;const i=document.createElement("div");i.className="fp-playlist-controls-item-content";const s=document.createElement("div");s.className="fp-playlist-controls-item-title",s.textContent=t.title||(null===(e=t.metadata)||void 0===e?void 0:e.title)||"";const l=document.createElement("div");return l.className="fp-playlist-controls-item-desc",l.textContent=t.description||(null===(n=t.metadata)||void 0===n?void 0:n.description)||"",i.append(s,l),i}itemHeader(t,e){var n,i;const s=document.createElement("div");s.className="fp-playlist-controls-item-header";const l=document.createElement("img");l.alt=e.title||(null===(n=e.metadata)||void 0===n?void 0:n.title)||"",l.className="fp-playlist-controls-image",l.src=e.poster||"";const o=document.createElement("span");o.className="fp-playlist-controls-playing",o.textContent=t.i18n("playlist.now_playing","Now playing"),s.append(l,o);const r=e.duration||(null===(i=e.metadata)||void 0===i?void 0:i.duration);if(void 0!==r){const t=document.createElement("span");t.className="fp-playlist-controls-duration",t.textContent=isFinite(r)?function(t){if(isNaN(t)||t>=Number.MAX_SAFE_INTEGER)return"";const e=t<0?"-":"";t=Math.round(Math.abs(t));const n=Math.floor(t/3600);let i=Math.floor(t/60);return t-=60*i,n>=1?(i-=60*n,e+n+":"+h(i)+":"+h(t)):e+h(i)+":"+h(t)}(r):"",s.append(t)}return s}controlsHeader(e){const n=document.createElement("div");n.className="fp-playlist-controls-header";const i=document.createElement("input");i.type="checkbox",i.className="fp-playlist-toggle",i.id="toggle";const s=document.createElement("label");s.className="fp-playlist-label",s.tabIndex=0,s.setAttribute("role","button"),s.setAttribute("for","toggle");const l=document.createElement("span");return l.textContent=e.i18n("playlist.autoplay","Autoplay"),s.addEventListener("click",t=>{t.preventDefault();const n=!i.checked;i.checked=n,Object.assign(e.opts.playlist,{advance:n}),s.ariaPressed=n+"",s.ariaLabel=n?e.i18n("playlist.turn_off_autoplay","Turn off autoplay"):e.i18n("playlist.autoplay","Autoplay")}),e.on(t.PLAYLIST_READY,()=>{var t,n;const l=null===(n=null===(t=e.opts)||void 0===t?void 0:t.playlist)||void 0===n?void 0:n.advance;i.checked=!1!==l,s.ariaPressed=""+(!1!==l),s.ariaLabel=!1!==l?e.i18n("playlist.turn_off_autoplay","Turn off autoplay"):e.i18n("playlist.autoplay","Autoplay")}),n.append(l,i,s),n}videoRow_onclick(t,e){var n;if(t.classList.contains("is-current"))return;const i=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==i&&(null===(n=e.playlist)||void 0===n||n.play(i))}}var v;function L(t,e){var n,i;const s=e.sort||x,l=null!==(n=e.mode)&&void 0!==n?n:v.FIFO;return t=s(t.slice(0),l),{mode:l,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function E(t){return t.idx==t.last_idx}function b(t){const e=t.idx+1;return e>t.last_idx?0:e}function A(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}function x(t,e){return(e&v.SHUFFLE)==v.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return L(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(v||(v={})),function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const w=["touchstart","touchmove"];function _(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function I(t,e,n,i){Array.isArray(e)?e.forEach(e=>g(t,e,n,i)):g(t,e,n,i)}function g(t,e,n,i){if(s=e,!~w.indexOf(s))return t.addEventListener(e,n,i),t;var s;const l=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,l),t}function S(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function P(t,e,n){return t.setAttribute(e,n),t}function N(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function O(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function q(e,n,i){const s=n.idx+n.plays<0;if(!s&&i.delay)return function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue,l=S(e,"flowplayer-playlist-interstitial");if(!l||!s||!n.delay)return;e.root.classList.add("is-interstitial");const o=s.members[b(s)];_(l,t.INTERSTITIAL_NEXT_ITEM,{next:o})}(e,i);C(e,A(n,s,i.start_index),s)}function C(e,n,i){i||(e.preload=n.preload="auto",!e.opts.autoplay&&e.setOpts({autoplay:1})),e.emit("playlist/advance"),"object"==typeof n&&e.setOpts(n),function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!s)return;const l=s.idx,o=s.members[l],r=e.currentSrc;if(o.src&&e.setSrc(o.src),e.emit(t.PLAYLIST_NEXT,{next_index:l}),e.opts.autoplay||n)return;const a=n=>{("canplay"===n.type&&r!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",a),e.removeEventListener(t.PLAYLIST_NEXT,a),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],a)}(e,i)}function Y(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,C(e,n.members[t]))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=T(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function k(e){const n=y(e,"flowplayer-skip-previous-icon");P(n,"role","button"),I(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");P(i,"role","button"),I(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=O("fp-playlist-prev-preview"),l=O("fp-playlist-next-preview"),o=S(e,"flowplayer-control-buttons");return o&&(o.prepend(n),o.append(i),o.append(s),o.append(l)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=m(t,"data.queue",m(e,"playlist.queue"));if(!n||!o||!e.skip_controls)return;N(o,"is-prev-button-disabled",!n.idx),N(o,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!E(t)||0!=(t.mode&v.LOOP))return t.members[b(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&v.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;l.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:l}}function D(t,e){if(!e)return;!1!==e.skip_controls&&(t.skip_controls=k(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");n.append(s)}function F(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?v.SHUFFLE:v.FIFO;return e.loop&&(n|=v.LOOP),L(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function R(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),l=null===(n=t.detail)||void 0===n?void 0:n.queue,o=null===(i=t.detail)||void 0===i?void 0:i.should_play;l&&s&&(e.playlist=Y(e,l),o&&q(e,l,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?E(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=T(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return q(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&q(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking","src"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=S(e,"flowplayer-playlist-interstitial");n&&_(n,t.INTERSTITIAL_CANCEL)}))}var M;const j=((M=class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:5,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),D(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{var t;e.root.classList.remove("is-interstitial");const n=null===(t=e.playlist)||void 0===t?void 0:t.queue;n&&C(e,A(n,!1))}),null===(n=S(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),R(i)}onload(e,n,i,s){F(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,M);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,j)}));
@@ -344,6 +344,7 @@ declare type ErrorEventDetail = {
344
344
  declare namespace events {
345
345
  export {
346
346
  MOUNT,
347
+ RETRY,
347
348
  ERROR,
348
349
  CONTEXT_MENU,
349
350
  CLICK,
@@ -395,7 +396,8 @@ declare namespace events {
395
396
  LANDSCAPE,
396
397
  PORTRAIT,
397
398
  DVR,
398
- LIVE_2 as LIVE
399
+ LIVE,
400
+ RECOVER
399
401
  }
400
402
  }
401
403
 
@@ -594,8 +596,6 @@ declare const /**
594
596
  */
595
597
  LANDSCAPE = "landscape";
596
598
 
597
- declare const LIVE = "is-live";
598
-
599
599
  /**
600
600
  * @public
601
601
  * when src is a livestream
@@ -607,7 +607,9 @@ declare const /**
607
607
  * @public
608
608
  * when src is a livestream
609
609
  */
610
- LIVE_2 = "live";
610
+ LIVE = "live";
611
+
612
+ declare const LIVE_2 = "is-live";
611
613
 
612
614
  declare const LIVE_SEEKED = "is-live-seeked";
613
615
 
@@ -907,33 +909,27 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
907
909
 
908
910
  declare type PlayerCustomEventName = keyof PlayerCustomEventsDetailMap;
909
911
 
910
- declare type PlayerCustomEventsDetailMap = {
911
- [MOUNT]: MountEventDetail;
912
- [ERROR]: ErrorEventDetail;
913
- [CONTEXT_MENU]: ContextMenuEventDetail;
914
- /* Excluded from this release type: beforeplay */
915
- /* Excluded from this release type: beforepause */
916
- /* Excluded from this release type: state */
912
+ declare type PlayerCustomEventsDetailMap = PlayerEmittableCustomEventsDetailMap & {
913
+ [REAP]: ReapEventDetail;
914
+ [SOURCE]: SourceEventDetail;
917
915
  [CUEPOINT_START]: CuePointStartEventDetail;
918
916
  [CUEPOINT_END]: CuePointEndEventDetail;
919
- [VIEW_ENTER]: ViewEnterEventDetail;
920
- [VIEW_LEAVE]: ViewLeaveEventDetail;
921
- [SOURCE]: SourceEventDetail;
922
- /* Excluded from this release type: recover */
923
- [REAP]: ReapEventDetail;
924
- /* Excluded from this release type: config */
925
- [QUALITIES]: QualitiesEventDetail;
926
- /* Excluded from this release type: "error:fatal" */
927
- [RECOMMENDATIONS_READY]: RecommendationsReadyEventDetail;
917
+ [MOUNT]: MountEventDetail;
918
+ [LIVE]: LiveEventDetail;
919
+ [DVR]: DvrEventDetail;
920
+ [RETRY]: RetryEventDetail;
921
+ [RECOVER]: RecoverEventDetail;
928
922
  /* Excluded from this release type: audioonlysource */
929
923
  /* Excluded from this release type: renderplugin */
930
- [DVR]: DvrEventDetail;
931
- [LIVE_2]: LiveEventDetail;
932
924
  /* Excluded from this release type: "seek:queued" */
933
925
  /* Excluded from this release type: "seek:cancel" */
934
926
  /* Excluded from this release type: "plugin:registered" */
935
927
  /* Excluded from this release type: intersectionchange */
936
- /* Excluded from this release type: retry */
928
+ /* Excluded from this release type: beforeplay */
929
+ /* Excluded from this release type: beforepause */
930
+ /* Excluded from this release type: state */
931
+ /* Excluded from this release type: config */
932
+ /* Excluded from this release type: "error:fatal" */
937
933
  };
938
934
 
939
935
  declare type PlayerCustomEventsOverloads = {
@@ -972,11 +968,18 @@ declare type PlayerCustomEventsOverloads = {
972
968
  * Sent right before the player src attribute is set. This allows you to change the video URL before playback.
973
969
  */
974
970
  on(event: typeof SOURCE, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof SOURCE]>) => void): Player;
975
- /* Excluded from this release type: on */
971
+ /**
972
+ * Emitted when an Error recovery is attempted
973
+ */
974
+ on(event: typeof RECOVER, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof RECOVER]>) => void): Player;
976
975
  /**
977
976
  * Sent when a flowplayer instance is about to be removed from the DOM, and any unsafe references are about to be reaped, which allows Single Page Applications to perform the necessary resource cleanups. This is important when working with front-end frameworks like React. This event should never be emitted directly, only listened to.
978
977
  */
979
978
  on(event: typeof REAP, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof REAP]>) => void): Player;
979
+ /**
980
+ * Emitted when a player will retry to reload
981
+ */
982
+ on(event: typeof RETRY, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof RETRY]>) => void): Player;
980
983
  /* Excluded from this release type: on */
981
984
  /**
982
985
  * Emitted when the set of underlying qualities has changed.
@@ -996,8 +999,7 @@ declare type PlayerCustomEventsOverloads = {
996
999
  /**
997
1000
  * when src is a livestream
998
1001
  */
999
- on(event: typeof LIVE_2, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof LIVE_2]>) => void): Player;
1000
- /* Excluded from this release type: on */
1002
+ on(event: typeof LIVE, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof LIVE]>) => void): Player;
1001
1003
  /* Excluded from this release type: on */
1002
1004
  /* Excluded from this release type: on */
1003
1005
  /* Excluded from this release type: on */
@@ -1026,11 +1028,26 @@ declare type PlayerCustomEventsOverloads = {
1026
1028
  */
1027
1029
  off<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1028
1030
  /* Excluded from this release type: poll */
1029
- emit<T extends PlayerCustomEventName>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1030
1031
  /* Excluded from this release type: emit */
1031
- emit<T, X extends string = string>(event: X & (X extends PlayerCustomEventName ? "Incorrect event detail type" : X), data?: T): Player;
1032
+ /* Excluded from this release type: emit */
1033
+ emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1034
+ /* Excluded from this release type: emit */
1035
+ };
1036
+
1037
+ declare type PlayerEmittableCustomEventsDetailMap = {
1038
+ [ERROR]: ErrorEventDetail;
1039
+ [CONTEXT_MENU]: ContextMenuEventDetail;
1040
+ [VIEW_ENTER]: ViewEnterEventDetail;
1041
+ [VIEW_LEAVE]: ViewLeaveEventDetail;
1042
+ [QUALITIES]: QualitiesEventDetail;
1043
+ [RECOMMENDATIONS_READY]: RecommendationsReadyEventDetail;
1032
1044
  };
1033
1045
 
1046
+ declare type PlayerEmittableEventNames = keyof PlayerEmittableCustomEventsDetailMap;
1047
+
1048
+ /**
1049
+ * @public
1050
+ */
1034
1051
  declare type PlayerEventOverloads = PlayerNativeEventsOverloads & PlayerCustomEventsOverloads;
1035
1052
 
1036
1053
  declare type PlayerNativeEventName = keyof PlayerNativeEventsDetailMap;
@@ -1230,9 +1247,23 @@ declare type RecommendationsReadyEventDetail = {
1230
1247
  playlist: RecommendationItem[];
1231
1248
  };
1232
1249
 
1233
- /* Excluded from this release type: RECOVER */
1250
+ /**
1251
+ * @public
1252
+ * emitted when an Error recovery is attempted
1253
+ */
1254
+ declare const /**
1255
+ @public
1256
+ * when a new player is inserted into the HTML
1257
+ */ /**
1258
+ * @public
1259
+ * emitted when an Error recovery is attempted
1260
+ */
1261
+ RECOVER = "recover";
1234
1262
 
1235
- /* Excluded from this release type: RecoverEventDetail */
1263
+ /**
1264
+ * @public
1265
+ */
1266
+ declare type RecoverEventDetail = null;
1236
1267
 
1237
1268
  /* Excluded from this release type: REMOTE_SESSION_ENDED */
1238
1269
 
@@ -1256,9 +1287,21 @@ declare const /**
1256
1287
  */
1257
1288
  RESIZE = "resize";
1258
1289
 
1259
- /* Excluded from this release type: RETRY */
1290
+ /**
1291
+ * @public
1292
+ */
1293
+ declare const /**
1294
+ @public
1295
+ * when a new player is inserted into the HTML
1296
+ */ /**
1297
+ * @public
1298
+ */
1299
+ RETRY = "retry";
1260
1300
 
1261
- /* Excluded from this release type: RetryEventDetail */
1301
+ /**
1302
+ * @public
1303
+ */
1304
+ declare type RetryEventDetail = null;
1262
1305
 
1263
1306
  declare const RTL = "is-rtl";
1264
1307
 
@@ -1393,7 +1436,7 @@ declare namespace states {
1393
1436
  RTL,
1394
1437
  TV,
1395
1438
  ENDED,
1396
- LIVE,
1439
+ LIVE_2 as LIVE,
1397
1440
  ERRORED,
1398
1441
  WAITING,
1399
1442
  AUTOPLAY,