@flowplayer/player 3.22.0-rc → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +2 -2
- package/package.json +1 -1
- package/plugins/ads.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/endscreen.js +1 -1
- package/plugins/media-session.js +1 -1
- package/plugins/playlist.d.ts +179 -2
- package/plugins/playlist.js +1 -1
- package/plugins/ssai.d.ts +338 -11
- package/plugins/ssai.js +1 -1
package/plugins/playlist.d.ts
CHANGED
|
@@ -366,6 +366,22 @@ declare type ErrorEventDetail = {
|
|
|
366
366
|
/* Excluded from this release type: _ErrorEventDetail */
|
|
367
367
|
|
|
368
368
|
declare namespace events {
|
|
369
|
+
export {
|
|
370
|
+
PLAYLIST_NEXT,
|
|
371
|
+
PLAYLIST_PREVIOUS,
|
|
372
|
+
PLAYLIST_SELECTION,
|
|
373
|
+
PLAYLIST_LOOP,
|
|
374
|
+
PLAYLIST_ENDED,
|
|
375
|
+
PLAYLIST_READY,
|
|
376
|
+
PLAYLIST_ADD,
|
|
377
|
+
PLAYLIST_REMOVE,
|
|
378
|
+
INTERSTITIAL_END,
|
|
379
|
+
INTERSTITIAL_CANCEL,
|
|
380
|
+
INTERSTITIAL_NEXT_ITEM
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
declare namespace events_2 {
|
|
369
385
|
export {
|
|
370
386
|
MOUNT,
|
|
371
387
|
RETRY,
|
|
@@ -493,7 +509,7 @@ declare interface FlowplayerUMDBase {
|
|
|
493
509
|
/**
|
|
494
510
|
* Flowplayer core events
|
|
495
511
|
*/
|
|
496
|
-
events: typeof
|
|
512
|
+
events: typeof events_2;
|
|
497
513
|
/**
|
|
498
514
|
* Flowplayer ui states map
|
|
499
515
|
*/
|
|
@@ -595,6 +611,12 @@ declare const IN_VIEWPORT = "is-in-viewport";
|
|
|
595
611
|
|
|
596
612
|
/* Excluded from this release type: IntersectionChangeEventDetail */
|
|
597
613
|
|
|
614
|
+
declare const INTERSTITIAL_CANCEL = "interstitial/cancel";
|
|
615
|
+
|
|
616
|
+
declare const INTERSTITIAL_END = "interstitial/end";
|
|
617
|
+
|
|
618
|
+
declare const INTERSTITIAL_NEXT_ITEM = "interstitial/next_item";
|
|
619
|
+
|
|
598
620
|
declare const IS_SOURCE_PROCESSING = "is-source-processing";
|
|
599
621
|
|
|
600
622
|
declare type JSONPlayer = any;
|
|
@@ -1161,10 +1183,35 @@ PLAYING_2 = "playing";
|
|
|
1161
1183
|
|
|
1162
1184
|
/**
|
|
1163
1185
|
* @public
|
|
1186
|
+
* The Playlist plugin adds support for player playlists. With playlists, you can organize related videos into a cohesive sequence, making it easier to manage large amounts of content. Users can quickly navigate through videos in a structured way without having to search for individual items.
|
|
1187
|
+
* See {@link https://developer.wowza.com/docs/wowza-flowplayer/plugins/playlist/| Official documentation}
|
|
1164
1188
|
*/
|
|
1165
|
-
declare const Playlist: PluginCtor<NoInfer<PlaylistConfig>, NoInfer<
|
|
1189
|
+
declare const Playlist: PluginCtor<NoInfer<PlaylistConfig>, NoInfer<PlaylistPlayer>> & NoInfer<PlaylistAPI>;
|
|
1166
1190
|
export default Playlist;
|
|
1167
1191
|
|
|
1192
|
+
declare const PLAYLIST_ADD = "playlist:add";
|
|
1193
|
+
|
|
1194
|
+
declare const PLAYLIST_ENDED = "playlist:ended";
|
|
1195
|
+
|
|
1196
|
+
declare const PLAYLIST_LOOP = "playlist:loop";
|
|
1197
|
+
|
|
1198
|
+
declare const PLAYLIST_NEXT = "playlist:next";
|
|
1199
|
+
|
|
1200
|
+
declare const PLAYLIST_PREVIOUS = "playlist:previous";
|
|
1201
|
+
|
|
1202
|
+
declare const PLAYLIST_READY = "playlist:ready";
|
|
1203
|
+
|
|
1204
|
+
declare const PLAYLIST_REMOVE = "playlist:remove";
|
|
1205
|
+
|
|
1206
|
+
declare const PLAYLIST_SELECTION = "playlist:selection";
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* @public
|
|
1210
|
+
*/
|
|
1211
|
+
export declare type PlaylistAPI = {
|
|
1212
|
+
events: PlaylistEvents;
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1168
1215
|
/**
|
|
1169
1216
|
* @public
|
|
1170
1217
|
*/
|
|
@@ -1173,8 +1220,91 @@ export declare type PlaylistConfig = ConfigWith<{
|
|
|
1173
1220
|
playlist?: PlaylistProperties;
|
|
1174
1221
|
}>;
|
|
1175
1222
|
|
|
1223
|
+
/**
|
|
1224
|
+
* @public
|
|
1225
|
+
*/
|
|
1226
|
+
export declare type PlaylistEndedEvent = FPEvent<PlaylistEndedEventDetail>;
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* @public
|
|
1230
|
+
*/
|
|
1231
|
+
export declare type PlaylistEndedEventDetail = null;
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* @public
|
|
1235
|
+
*/
|
|
1236
|
+
export declare type PlaylistEvents = typeof events;
|
|
1237
|
+
|
|
1176
1238
|
/* Excluded from this release type: PlaylistMetadata */
|
|
1177
1239
|
|
|
1240
|
+
/**
|
|
1241
|
+
* @public
|
|
1242
|
+
*/
|
|
1243
|
+
export declare type PlaylistNextEvent = FPEvent<PlaylistNextEventDetail>;
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* @public
|
|
1247
|
+
*/
|
|
1248
|
+
export declare type PlaylistNextEventDetail = {
|
|
1249
|
+
next_index: number;
|
|
1250
|
+
};
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* @public
|
|
1254
|
+
*/
|
|
1255
|
+
export declare type PlaylistPlayer = PlayerWith<{
|
|
1256
|
+
playlist?: PlaylistPlayerAPI;
|
|
1257
|
+
/**
|
|
1258
|
+
* Fires when the playlist is updated. Gets the updated video queue as parameter queue.
|
|
1259
|
+
*/
|
|
1260
|
+
on(name: PlaylistEvents["PLAYLIST_READY"], handler: (e: PlaylistReadyEvent) => void): PlaylistPlayer;
|
|
1261
|
+
/**
|
|
1262
|
+
* Fires when the playlist advances.
|
|
1263
|
+
*/
|
|
1264
|
+
on(name: PlaylistEvents["PLAYLIST_NEXT"], handler: (e: PlaylistNextEvent) => void): PlaylistPlayer;
|
|
1265
|
+
/**
|
|
1266
|
+
* Fires when the playlist is finished.
|
|
1267
|
+
*/
|
|
1268
|
+
on(name: PlaylistEvents["PLAYLIST_ENDED"], handler: (e: PlaylistEndedEvent) => void): PlaylistPlayer;
|
|
1269
|
+
/* Excluded from this release type: skip_controls */
|
|
1270
|
+
/* Excluded from this release type: on */
|
|
1271
|
+
}>;
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* @public
|
|
1275
|
+
*/
|
|
1276
|
+
export declare type PlaylistPlayerAPI = {
|
|
1277
|
+
/**
|
|
1278
|
+
* Exposes the current playlist queue, including its idx, members, last_index properties.
|
|
1279
|
+
*/
|
|
1280
|
+
queue: VideoQueue;
|
|
1281
|
+
/**
|
|
1282
|
+
* Plays the video at index idx.
|
|
1283
|
+
*/
|
|
1284
|
+
play(idx: number): void;
|
|
1285
|
+
/**
|
|
1286
|
+
* Plays the next video.
|
|
1287
|
+
*/
|
|
1288
|
+
next(): void;
|
|
1289
|
+
/**
|
|
1290
|
+
* Plays the previous video.
|
|
1291
|
+
*/
|
|
1292
|
+
prev(): void;
|
|
1293
|
+
/**
|
|
1294
|
+
* Remove video at index idx.
|
|
1295
|
+
*/
|
|
1296
|
+
remove(idx: number): void;
|
|
1297
|
+
/**
|
|
1298
|
+
* Pushes a new video to the queue. Accepts one/several player configuration object(s)
|
|
1299
|
+
*/
|
|
1300
|
+
push(...members: Config[]): void;
|
|
1301
|
+
/**
|
|
1302
|
+
* Clear whole queue.
|
|
1303
|
+
*/
|
|
1304
|
+
clear(): void;
|
|
1305
|
+
/* Excluded from this release type: events */
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1178
1308
|
/**
|
|
1179
1309
|
* @public
|
|
1180
1310
|
*/
|
|
@@ -1210,11 +1340,26 @@ export declare type PlaylistProperties = {
|
|
|
1210
1340
|
shuffle?: boolean;
|
|
1211
1341
|
};
|
|
1212
1342
|
|
|
1343
|
+
/**
|
|
1344
|
+
* @public
|
|
1345
|
+
*/
|
|
1346
|
+
export declare type PlaylistReadyEvent = FPEvent<PlaylistReadyEventDetail>;
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* @public
|
|
1350
|
+
*/
|
|
1351
|
+
export declare type PlaylistReadyEventDetail = {
|
|
1352
|
+
queue: VideoQueue;
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1213
1355
|
/**
|
|
1214
1356
|
* @public
|
|
1215
1357
|
*/
|
|
1216
1358
|
export declare type PlaylistSource = {
|
|
1217
1359
|
type: "flowplayer/playlist";
|
|
1360
|
+
/**
|
|
1361
|
+
* playlist elements queue
|
|
1362
|
+
*/
|
|
1218
1363
|
items: QueueMembers;
|
|
1219
1364
|
};
|
|
1220
1365
|
|
|
@@ -1334,6 +1479,15 @@ declare enum QualityOpts {
|
|
|
1334
1479
|
*/
|
|
1335
1480
|
export declare type QueueMembers = Array<Config>;
|
|
1336
1481
|
|
|
1482
|
+
/**
|
|
1483
|
+
* @public
|
|
1484
|
+
*/
|
|
1485
|
+
export declare enum QueueModes {
|
|
1486
|
+
SHUFFLE = 1,
|
|
1487
|
+
FIFO = 2,
|
|
1488
|
+
LOOP = 4
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1337
1491
|
/**
|
|
1338
1492
|
* @public
|
|
1339
1493
|
* emitted when it is safe to clean up a fp instance
|
|
@@ -1509,6 +1663,8 @@ declare const /**
|
|
|
1509
1663
|
*/
|
|
1510
1664
|
SET_QUALITY = "quality:set";
|
|
1511
1665
|
|
|
1666
|
+
/* Excluded from this release type: SkipControls */
|
|
1667
|
+
|
|
1512
1668
|
declare const SMALL = "is-small";
|
|
1513
1669
|
|
|
1514
1670
|
/**
|
|
@@ -1694,6 +1850,27 @@ declare const /**
|
|
|
1694
1850
|
*/
|
|
1695
1851
|
VIDEO_TRACKS = "videoTracks";
|
|
1696
1852
|
|
|
1853
|
+
/**
|
|
1854
|
+
* @public
|
|
1855
|
+
*/
|
|
1856
|
+
export declare type VideoQueue = {
|
|
1857
|
+
/**
|
|
1858
|
+
* index of the video currently playing.
|
|
1859
|
+
*/
|
|
1860
|
+
idx: number;
|
|
1861
|
+
/**
|
|
1862
|
+
* last possible index to play.
|
|
1863
|
+
*/
|
|
1864
|
+
last_idx: number;
|
|
1865
|
+
plays: number;
|
|
1866
|
+
/**
|
|
1867
|
+
* the videos in the playlist queue.
|
|
1868
|
+
*/
|
|
1869
|
+
members: QueueMembers;
|
|
1870
|
+
mode: QueueModes;
|
|
1871
|
+
sort?: (list: QueueMembers, mode: QueueModes) => QueueMembers;
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1697
1874
|
/**
|
|
1698
1875
|
* @public
|
|
1699
1876
|
* when a player enters the viewpoint
|
package/plugins/playlist.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.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{static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}constructor(t){this.data=t}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 a(t){return"string"==typeof t}function r(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)&&r(t)),l("property `playlist` is required",o(t.playlist)),l("property `playlist` was not a String(MediaId)",a(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",a(t)||r(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 a=document.createElement("span");a.classList.add("fp-icon","fp-play"),o.append(a);const r=document.createElement("span");r.classList.add("title"),r.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(r,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),m=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function f(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 use-play-1",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("div");o.className="fp-playlist-controls-playing";const a=new(window.customElements.get("flowplayer-play-icon"))(t);a.ariaHidden="true",a.tabIndex=-1;const r=document.createElement("span");r.textContent=t.i18n("playlist.now_playing","Now playing"),o.append(a,r),s.append(l,o);const c=e.duration||(null===(i=e.metadata)||void 0===i?void 0:i.duration);if(void 0!==c){const t=document.createElement("span");t.className="fp-playlist-controls-duration",t.textContent=isFinite(c)?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)}(c):"",s.append(t)}return s}controlsHeader(e){const n=document.createElement("div");n.className="fp-playlist-controls-header";const i=document.createElement("h3");i.id="title",i.className="fp-playlist-title",i.textContent="Playlist";const s=document.createElement("input");s.type="checkbox",s.className="fp-playlist-toggle-input",s.id="toggle";const l=document.createElement("label");l.className="fp-playlist-toggle-label",l.tabIndex=0,l.setAttribute("role","button"),l.setAttribute("for","toggle");const o=document.createElement("span");o.className="fp-playlist-toggle-title",o.textContent=e.i18n("playlist.autoplay","Autoplay");const a=document.createElement("div");return a.className="fp-playlist-toggle",a.append(o,s,l),l.addEventListener("click",t=>{t.preventDefault();const n=!s.checked;s.checked=n;const i=e.opts;i.playlist||(i.playlist={}),Object.assign(i.playlist,{advance:n}),l.ariaPressed=n+"",l.ariaLabel=n?e.i18n("playlist.turn_off_autoplay","Turn off autoplay"):e.i18n("playlist.autoplay","Autoplay")}),e.on(t.PLAYLIST_READY,()=>{var t,n,o;const a=e.opts,r=null===(t=null==a?void 0:a.playlist)||void 0===t?void 0:t.advance;s.checked=!1!==r,l.ariaPressed=""+(!1!==r),l.ariaLabel=!1!==r?e.i18n("playlist.turn_off_autoplay","Turn off autoplay"):e.i18n("playlist.autoplay","Autoplay"),i.textContent=null!==(o=null===(n=null==a?void 0:a.metadata)||void 0===n?void 0:n.playlist_title)&&void 0!==o?o:"Playlist"}),n.append(i,a),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 E(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 L(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 w(t){return E(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 T=["touchstart","touchmove"];function g(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 _(t,e,n,i){Array.isArray(e)?e.forEach(e=>I(t,e,n,i)):I(t,e,n,i)}function I(t,e,n,i){if(s=e,!~T.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 P(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function S(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 C(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function O(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=P(e,"flowplayer-playlist-interstitial");if(!l||!s||!n.delay)return;e.root.classList.add("is-interstitial");const o=s.members[b(s)];g(l,t.INTERSTITIAL_NEXT_ITEM,{next:o})}(e,i);q(e,A(n,s,i.start_index),s)}function q(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],a=e.currentSrc;if(o.src&&e.setSrc(o.src),e.emit(t.PLAYLIST_NEXT,{next_index:l}),e.opts.autoplay||n)return;const r=n=>{("canplay"===n.type&&a!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",r),e.removeEventListener(t.PLAYLIST_NEXT,r),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],r)}(e,i)}function Y(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,q(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=w(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");S(n,"role","button"),_(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");S(i,"role","button"),_(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=C("fp-playlist-prev-preview"),l=C("fp-playlist-next-preview"),o=P(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=f(t,"data.queue",f(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(!L(t)||0!=(t.mode&v.LOOP))return t.members[b(t)]}(n):null,a=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(",a?a.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,!a(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:a(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),E(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&&O(e,l,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?L(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=w(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return O(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&O(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=P(e,"flowplayer-playlist-interstitial");n&&g(n,t.INTERSTITIAL_CANCEL)}))}var M;const j=((M=class Playlist{constructor(t){m(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),m(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),m(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),m(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&&q(e,A(n,!1))}),null===(n=P(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)}));
|
|
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=Object.freeze({__proto__:null,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{static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}constructor(t){this.data=t}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 a(t){return"string"==typeof t}function r(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function p(t){var e;l("Config must be an Object",o(t)&&r(t)),l("property `playlist` is required",o(t.playlist)),l("property `playlist` was not a String(MediaId)",a(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",a(t)||r(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 u(t){try{p(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(t){super(t),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent("interstitial/end"))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent("interstitial/cancel"))}),this.addEventListener("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 t,e;this.innerHTML="",this.classList.remove("cancelled");const n=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const s=document.createElement("div");s.classList.add("pane","right"),n.append(i,s);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",i.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent("interstitial/end")));const o=document.createElement("span");o.classList.add("fp-icon","fp-play"),l.append(o);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const r=document.createElement("span");r.classList.add("description"),r.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(e=null===(t=this.player)||void 0===t?void 0:t.i18n("playlist.cancel"))&&void 0!==e?e:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),s.append(a,r,p,c),this.append(n)}_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),m=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function f(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 v(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(t){super(t),this.playlistWrapper=document.createElement("ol"),this.className="fp-playlist-controls is-empty use-play-1",this.header=this.controlsHeader(t),this.append(this.header,this.playlistWrapper),t.on("playlist:ready",e=>{const n=e.detail.queue;n&&(this.list(n,t),this.classList.toggle("is-empty",!n.members.length))}),t.on("playlist:next",()=>{var e;(null===(e=t.playlist)||void 0===e?void 0:e.queue)&&Array.from(this.querySelectorAll("li")).forEach((e,n)=>{var i;const s=n===(null===(i=t.playlist)||void 0===i?void 0:i.queue.idx);e.classList.toggle("is-current",s),e.setAttribute("aria-current",""+s)})}),t.on("playlist:add",e=>{var n;const i=null===(n=t.playlist)||void 0===n?void 0:n.queue;if(!e.data||!i)return;e.data.members.forEach(e=>{const n=this.videoRow(e,t);n&&this.playlistWrapper.append(n)})}),t.on("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("div");o.className="fp-playlist-controls-playing";const a=new(window.customElements.get("flowplayer-play-icon"))(t);a.ariaHidden="true",a.tabIndex=-1;const r=document.createElement("span");r.textContent=t.i18n("playlist.now_playing","Now playing"),o.append(a,r),s.append(l,o);const c=e.duration||(null===(i=e.metadata)||void 0===i?void 0:i.duration);if(void 0!==c){const t=document.createElement("span");t.className="fp-playlist-controls-duration",t.textContent=isFinite(c)?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+":"+v(i)+":"+v(t)):e+v(i)+":"+v(t)}(c):"",s.append(t)}return s}controlsHeader(t){const e=document.createElement("div");e.className="fp-playlist-controls-header";const n=document.createElement("h3");n.id="title",n.className="fp-playlist-title",n.textContent="Playlist";const i=document.createElement("input");i.type="checkbox",i.className="fp-playlist-toggle-input",i.id="toggle";const s=document.createElement("label");s.className="fp-playlist-toggle-label",s.tabIndex=0,s.setAttribute("role","button"),s.setAttribute("for","toggle");const l=document.createElement("span");l.className="fp-playlist-toggle-title",l.textContent=t.i18n("playlist.autoplay","Autoplay");const o=document.createElement("div");return o.className="fp-playlist-toggle",o.append(l,i,s),s.addEventListener("click",e=>{e.preventDefault();const n=!i.checked;i.checked=n;const l=t.opts;l.playlist||(l.playlist={}),Object.assign(l.playlist,{advance:n}),s.ariaPressed=n+"",s.ariaLabel=n?t.i18n("playlist.turn_off_autoplay","Turn off autoplay"):t.i18n("playlist.autoplay","Autoplay")}),t.on("playlist:ready",()=>{var e,l,o;const a=t.opts,r=null===(e=null==a?void 0:a.playlist)||void 0===e?void 0:e.advance;i.checked=!1!==r,s.ariaPressed=""+(!1!==r),s.ariaLabel=!1!==r?t.i18n("playlist.turn_off_autoplay","Turn off autoplay"):t.i18n("playlist.autoplay","Autoplay"),n.textContent=null!==(o=null===(l=null==a?void 0:a.metadata)||void 0===l?void 0:l.playlist_title)&&void 0!==o?o:"Playlist"}),e.append(n,o),e}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 h;function x(t,e){var n,i;const s=e.sort||g,l=null!==(n=e.mode)&&void 0!==n?n:h.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 b(t){return t.idx==t.last_idx}function E(t){const e=t.idx+1;return e>t.last_idx?0:e}function w(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&h.SHUFFLE)==h.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function L(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"}(h||(h={})),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 _=["touchstart","touchmove"];function A(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 P(t,e,n,i){Array.isArray(e)?e.forEach(e=>I(t,e,n,i)):I(t,e,n,i)}function I(t,e,n,i){if(s=e,!~_.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 q(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function O(t,e,n){return t.setAttribute(e,n),t}function T(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function k(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function C(t,e,n){const i=e.idx+e.plays<0;if(!i&&n.delay)return function(t,e){var n;const i=null===(n=t.playlist)||void 0===n?void 0:n.queue,s=q(t,"flowplayer-playlist-interstitial");if(!s||!i||!e.delay)return;t.root.classList.add("is-interstitial");const l=i.members[E(i)];A(s,"interstitial/next_item",{next:l})}(t,n);N(t,w(e,i,n.start_index),i)}function N(t,e,n){n||(t.preload=e.preload="auto",!t.opts.autoplay&&t.setOpts({autoplay:1})),t.emit("playlist/advance"),"object"==typeof e&&t.setOpts(e),function(t,e){var n;const i=null===(n=t.playlist)||void 0===n?void 0:n.queue;if(!i)return;const s=i.idx,l=i.members[s],o=t.currentSrc;if(l.src&&t.setSrc(l.src),t.emit("playlist:next",{next_index:s}),t.opts.autoplay||e)return;const a=e=>{("canplay"===e.type&&o!==t.currentSrc||"playlist:next"===e.type)&&(t.removeEventListener("canplay",a),t.removeEventListener("playlist:next",a),"canplay"===e.type&&t.togglePlay(!0))};t.on(["canplay","playlist:next"],a)}(t,n)}function S(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,N(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(t){const n=this.queue;return n.members[t]?n.idx===t?console.warn("operation failed: you cannot remove current playlist item"):(n.members.splice(t,1),n.last_idx=n.members.length-1,t<n.idx&&--n.idx,void e.emit("playlist:remove",{index:t})):console.warn("there is no playlist item at this index")},push:function(...t){const n=e.root;if(0==this.queue.idx&&n.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const i=this.queue.members;i.push(...t),this.queue.last_idx=i.length-1,e.emit("playlist:add",{members:t})},clear:function(){this.queue.members=[],this.queue.plays--,function(t,e){t.playlist&&(e=t.playlist.queue=L(e),t.emit("playlist:ready",{queue:e,should_play:!1}))}(e,this.queue)}}}function F(t){const e=y(t,"flowplayer-skip-previous-icon");O(e,"role","button"),P(e,"click",(function(){t.playlist&&t.playlist.prev()}));const n=y(t,"flowplayer-skip-next-icon");O(n,"role","button"),P(n,"click",(function(){t.playlist&&t.playlist.next()}));const i=k("fp-playlist-prev-preview"),s=k("fp-playlist-next-preview"),l=q(t,"flowplayer-control-buttons");return l&&(l.prepend(e),l.append(n),l.append(i),l.append(s)),t.on("reap",(function(){t.skip_controls=void 0})),t.on(["playlist:next","playlist:add","playlist:remove"],(function(e){const n=f(e,"data.queue",f(t,"playlist.queue"));if(!n||!l||!t.skip_controls)return;T(l,"is-prev-button-disabled",!n.idx),T(l,"is-next-button-disabled",n.idx===n.last_idx);const o=n.idx<n.last_idx?function(t){if(!b(t)||0!=(t.mode&h.LOOP))return t.members[E(t)]}(n):null,a=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&h.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;s.style.backgroundImage=["url(",o?o.poster:null,")"].join(""),i.style.backgroundImage=["url(",a?a.poster:null,")"].join("")})),{prevButton:e,nextButton:n,prevPreview:i,nextPreview:s}}function M(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,!a(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:a(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 j(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?h.SHUFFLE:h.FIFO;return e.loop&&(n|=h.LOOP),x(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function H(t){var e;t.on("playlist:ready",(function(e){var n,i;const s=t.opt("playlist",{}),l=null===(n=e.detail)||void 0===n?void 0:n.queue,o=null===(i=e.detail)||void 0===i?void 0:i.should_play;l&&s&&(t.playlist=S(t,l),o&&C(t,l,s))})),t.on("ended",(e=e=>{if(e.prevented_from_ads)return;const n=t.opt("playlist");return t.playlist&&n?b(t.playlist.queue)?function(t,e){if(t.emit("playlist:ended"),!e.loop)return;if(!t.playlist)return;const n=t.playlist.queue=L(t.playlist.queue);if(t.emit("playlist:loop"),!e.shuffle)return C(t,n,e);t.emit("playlist:ready",{queue:n,should_play:!0})}(t,n):void(!1!==n.advance&&C(t,t.playlist.queue,n)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return e(t)}),0)})),t.on(["playing","waiting","seeking","src"],(function(){if(!t.root.classList.contains("is-interstitial"))return;const e=q(t,"flowplayer-playlist-interstitial");e&&A(e,"interstitial/cancel")}))}var D;const R=((D=class Playlist{constructor(t){m(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),m(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),m(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),m(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(t,e,n){const i=t.playlist||{};i.delay="number"==typeof i.delay?i.delay:5,n.setOpts(Object.assign(Object.assign({},t),{playlist:i})),M(n,t.playlist),function(t){var e;const n=y(t,"flowplayer-playlist-interstitial");n.addEventListener("interstitial/cancel",()=>t.root.classList.remove("is-interstitial")),n.addEventListener("interstitial/end",()=>{var e;t.root.classList.remove("is-interstitial");const n=null===(e=t.playlist)||void 0===e?void 0:e.queue;n&&N(t,w(n,!1))}),null===(e=q(t,"flowplayer-ui"))||void 0===e||e.prepend(n)}(n),H(n)}onload(t,e,n,i){j(t.playlist||{},i.items,(function(t){n.setState("is-playlist",!0),n.emit("playlist:ready",{queue:t,should_play:0===n.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&u(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,D);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,R)}));
|