@flowplayer/player 3.10.4-rc.2 → 3.10.4-rc.3
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/index.d.ts +17 -11
- package/package.json +2 -1
- package/plugins/ads.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/cuepoints.d.ts +349 -0
- package/plugins/health.js +1 -1
- package/plugins/ssai.js +1 -1
- package/util/loader.d.ts +17 -11
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import type { MediaKeyFunc } from 'hls.js';
|
|
2
|
+
|
|
3
|
+
declare type AnyPlugin<PluginOwnConfig extends KeyValue> = Plugin_2<PluginOwnConfig> | Loader<PluginOwnConfig>;
|
|
4
|
+
|
|
5
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
6
|
+
|
|
7
|
+
declare type BitOpts = number;
|
|
8
|
+
|
|
9
|
+
declare type Component = {
|
|
10
|
+
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
11
|
+
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare interface Components {
|
|
15
|
+
render(key: string, args: any[]): void;
|
|
16
|
+
remove(key: string, args: any[]): void;
|
|
17
|
+
put(key: string, args: Component): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare interface Config {
|
|
21
|
+
src?: UnsafeSource;
|
|
22
|
+
preload?: "none" | "metadata" | "auto";
|
|
23
|
+
controls?: boolean;
|
|
24
|
+
lang?: string;
|
|
25
|
+
start_time?: number;
|
|
26
|
+
autopause?: boolean;
|
|
27
|
+
rewind?: boolean;
|
|
28
|
+
loop?: boolean;
|
|
29
|
+
seamless?: boolean;
|
|
30
|
+
retry?: boolean;
|
|
31
|
+
autoplay?: BitOpts;
|
|
32
|
+
start_quality?: BitOpts;
|
|
33
|
+
live?: boolean;
|
|
34
|
+
poster?: string;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
muted?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* is src handled by one of plugins loaders
|
|
39
|
+
*/
|
|
40
|
+
is_native?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* bitflags for UI options
|
|
43
|
+
*/
|
|
44
|
+
ui?: BitOpts;
|
|
45
|
+
/**
|
|
46
|
+
* your user access token
|
|
47
|
+
*/
|
|
48
|
+
token?: string;
|
|
49
|
+
/**
|
|
50
|
+
* manually configured duration for pre-rendering usually
|
|
51
|
+
*/
|
|
52
|
+
duration?: number;
|
|
53
|
+
/**
|
|
54
|
+
* can the content be seeked to any position
|
|
55
|
+
*/
|
|
56
|
+
seekable?: boolean;
|
|
57
|
+
multiplay?: boolean;
|
|
58
|
+
ratio?: number | string;
|
|
59
|
+
logo?: string;
|
|
60
|
+
logo_href?: string;
|
|
61
|
+
logo_alt_text?: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
/**
|
|
65
|
+
* the number of seconds to have in the buffer before dvr is activated
|
|
66
|
+
*/
|
|
67
|
+
seconds_to_dvr?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare namespace Configs {
|
|
71
|
+
export {
|
|
72
|
+
BitOpts,
|
|
73
|
+
FlowplayerCustomElementRegistry,
|
|
74
|
+
Config,
|
|
75
|
+
CustomConfig,
|
|
76
|
+
PluginConfig
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare type ConfigWith<T> = Configs.Config & T;
|
|
81
|
+
|
|
82
|
+
export declare type CueAttrs = {
|
|
83
|
+
startTime: number;
|
|
84
|
+
endTime: number;
|
|
85
|
+
text?: string;
|
|
86
|
+
id?: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export declare type CuepointList = Array<CueAttrs>;
|
|
90
|
+
|
|
91
|
+
declare class Cuepoints implements Plugin_2<CuepointsConfig> {
|
|
92
|
+
constructor(umd: FlowplayerUMD);
|
|
93
|
+
init(opts: CuepointsConfig, root: PlayerRoot, video: Player): void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export declare type CuepointsConfig = ConfigWith<CuepointsConfigNamespaced>;
|
|
97
|
+
|
|
98
|
+
declare type CuepointsConfigNamespaced = {
|
|
99
|
+
cuepoints?: CuepointList;
|
|
100
|
+
draw_cuepoints?: boolean;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
declare type CustomConfig<T> = Config & T;
|
|
104
|
+
|
|
105
|
+
declare const _default: typeof Cuepoints;
|
|
106
|
+
export default _default;
|
|
107
|
+
|
|
108
|
+
declare type DeviceId = string;
|
|
109
|
+
|
|
110
|
+
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
|
111
|
+
|
|
112
|
+
declare type DRMConfiguration = {
|
|
113
|
+
license_server: string;
|
|
114
|
+
http_headers?: Record<string, string>;
|
|
115
|
+
certificate?: string;
|
|
116
|
+
vendor?: string | DRMVendorImplementation;
|
|
117
|
+
request_media_key_system_access_function?: MediaKeyFunc;
|
|
118
|
+
query_params?: Record<string, string>;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
declare type DRMSourceConfiguration = {
|
|
122
|
+
[keysystem in DRM_KEYSYSTEM]?: DRMConfiguration;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
declare type DRMVendorImplementation = {
|
|
126
|
+
fairplay_fetch_certificate: (url: string, cb: (certificate_data: Uint8Array) => void) => void;
|
|
127
|
+
fairplay_request_license: (url: string, params: {
|
|
128
|
+
message: any;
|
|
129
|
+
assetId: string;
|
|
130
|
+
}, cb: (license_data: Uint8Array) => void) => void;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare namespace Flowplayer {
|
|
134
|
+
type SourceStr = Sources.SourceStr;
|
|
135
|
+
type DRM_KEYSYSTEM = Sources.DRM_KEYSYSTEM;
|
|
136
|
+
type SourceObj = Sources.SourceObj;
|
|
137
|
+
type DRMSourceConfiguration = Sources.DRMSourceConfiguration;
|
|
138
|
+
type SourceWith<T> = Sources.SourceWith<T>;
|
|
139
|
+
type UnsafeSource = Sources.UnsafeSource;
|
|
140
|
+
type SourceList = Sources.SourceList;
|
|
141
|
+
type DRMConfiguration = Sources.DRMConfiguration;
|
|
142
|
+
type DRMVendorImplementation = Sources.DRMVendorImplementation;
|
|
143
|
+
type BitOpts = Configs.BitOpts;
|
|
144
|
+
type FlowplayerCustomElementRegistry = Configs.FlowplayerCustomElementRegistry;
|
|
145
|
+
interface Config extends Configs.Config {
|
|
146
|
+
}
|
|
147
|
+
type CustomConfig<T> = Configs.CustomConfig<T>;
|
|
148
|
+
type PluginConfig<T> = Configs.PluginConfig<T>;
|
|
149
|
+
interface VideoTrack extends Players.VideoTrack {
|
|
150
|
+
}
|
|
151
|
+
interface FPEvent<T> extends Players.FPEvent<T> {
|
|
152
|
+
}
|
|
153
|
+
type DeviceId = Players.DeviceId;
|
|
154
|
+
type JSONPlayer = Players.JSONPlayer;
|
|
155
|
+
type PlayerRoot = Players.PlayerRoot;
|
|
156
|
+
interface Player extends Players.Player {
|
|
157
|
+
}
|
|
158
|
+
type PlayerState = Players.PlayerState;
|
|
159
|
+
interface FlowplayerUMD extends FlowplayerUMDs.FlowplayerUMD {
|
|
160
|
+
}
|
|
161
|
+
interface Components extends FlowplayerUMDs.Components {
|
|
162
|
+
}
|
|
163
|
+
type Component = FlowplayerUMDs.Component;
|
|
164
|
+
enum AutoplayOpts {
|
|
165
|
+
OFF,
|
|
166
|
+
ON,
|
|
167
|
+
AUDIO_REQUIRED
|
|
168
|
+
}
|
|
169
|
+
enum QualityOpts {
|
|
170
|
+
LOW,
|
|
171
|
+
MEDIUM,
|
|
172
|
+
HIGH
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
177
|
+
|
|
178
|
+
declare interface FlowplayerUMD<ConfigWithPlugins extends Config = Config> {
|
|
179
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
180
|
+
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
181
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
182
|
+
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
183
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMD<CustomConfig<ArrayToIntersection<MapToConfigs<PluginCtors>>>>;
|
|
184
|
+
instances: Player[];
|
|
185
|
+
extensions: PluginCtor[];
|
|
186
|
+
events: Record<string, string>;
|
|
187
|
+
ads?: {
|
|
188
|
+
events: Record<string, string>;
|
|
189
|
+
};
|
|
190
|
+
states: Record<string, string>;
|
|
191
|
+
quality: typeof Flowplayer.QualityOpts;
|
|
192
|
+
commit: string;
|
|
193
|
+
version: string;
|
|
194
|
+
customElements: FlowplayerCustomElementRegistry;
|
|
195
|
+
defaultElements: Record<string, string>;
|
|
196
|
+
components: Components;
|
|
197
|
+
support: any;
|
|
198
|
+
autoplay: typeof Flowplayer.AutoplayOpts;
|
|
199
|
+
jwt: any;
|
|
200
|
+
loaders: any;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
declare namespace FlowplayerUMDs {
|
|
204
|
+
export {
|
|
205
|
+
FlowplayerUMD,
|
|
206
|
+
Components,
|
|
207
|
+
Component
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
declare interface FPEvent<T> extends CustomEvent<T> {
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated
|
|
214
|
+
the data attribute has been migrated to details to match the CustomEvent spec
|
|
215
|
+
more info: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
|
|
216
|
+
*/
|
|
217
|
+
data?: T;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare type JSONPlayer = any;
|
|
221
|
+
|
|
222
|
+
declare type KeyValue = Record<string, any>;
|
|
223
|
+
|
|
224
|
+
declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Plugin_2<PluginOwnConfig> {
|
|
225
|
+
onload<T = KeyValue>(config: PluginConfig<T>, root: PlayerRoot, video: Player, src?: SourceObj): void;
|
|
226
|
+
wants<S = SourceObj, T = KeyValue>(srcString: SourceStr, srcObj: S, config: PluginConfig<T>): boolean;
|
|
227
|
+
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
231
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
declare interface Player extends HTMLVideoElement {
|
|
235
|
+
renderPlugin: (pluginContainer: HTMLElement) => void;
|
|
236
|
+
toggleDisable: (flag: boolean) => void;
|
|
237
|
+
original_src: string;
|
|
238
|
+
root: PlayerRoot;
|
|
239
|
+
playerState: Record<string, boolean>;
|
|
240
|
+
reaper: Map<string, any> | 0;
|
|
241
|
+
hasState(state: PlayerState): boolean;
|
|
242
|
+
transitionState(to: PlayerState, from: PlayerState, timer?: number): void;
|
|
243
|
+
togglePlay(on?: boolean): Promise<void>;
|
|
244
|
+
toggleFullScreen(on?: boolean, state_only?: boolean): void;
|
|
245
|
+
toggleMute(on?: boolean): void;
|
|
246
|
+
destroy(): void;
|
|
247
|
+
render(): void;
|
|
248
|
+
render(component: string, args: any[]): void;
|
|
249
|
+
createComponents(...args: string[]): HTMLElement[];
|
|
250
|
+
setOpts(config: Config): void;
|
|
251
|
+
setSrc(sources: UnsafeSource): Player;
|
|
252
|
+
on<T>(event: string | string[], handler: (e: FPEvent<T>) => void): Player;
|
|
253
|
+
once<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
|
|
254
|
+
off<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
|
|
255
|
+
poll<T>(event: string, data?: T): FPEvent<T>;
|
|
256
|
+
emit<T>(event: string, data?: T): Player;
|
|
257
|
+
setAttrs(attrs: Config): Player;
|
|
258
|
+
opt<T>(key: string, fallback?: T): T;
|
|
259
|
+
enqueueSeek(offset: number): any;
|
|
260
|
+
setState(state: string, flag: boolean): Player;
|
|
261
|
+
toJSON(): JSONPlayer;
|
|
262
|
+
i18n(k: string, fallback?: string): string;
|
|
263
|
+
deviceId(): DeviceId;
|
|
264
|
+
live_state: {
|
|
265
|
+
dvr?: boolean;
|
|
266
|
+
dvr_window?: number;
|
|
267
|
+
};
|
|
268
|
+
opts: Config;
|
|
269
|
+
plugins: Array<Plugin_2 | Loader>;
|
|
270
|
+
dvr_offset?: number;
|
|
271
|
+
message?: {
|
|
272
|
+
events: Record<string, string>;
|
|
273
|
+
};
|
|
274
|
+
disabled: boolean;
|
|
275
|
+
started?: boolean;
|
|
276
|
+
token: string;
|
|
277
|
+
tracks?: VideoTrack[];
|
|
278
|
+
_customElements: FlowplayerCustomElementRegistry;
|
|
279
|
+
_storage: Storage;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare type PlayerRoot = HTMLElement & {
|
|
283
|
+
prevWidth?: number;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
declare namespace Players {
|
|
287
|
+
export {
|
|
288
|
+
VideoTrack,
|
|
289
|
+
PlayerState,
|
|
290
|
+
FPEvent,
|
|
291
|
+
DeviceId,
|
|
292
|
+
JSONPlayer,
|
|
293
|
+
PlayerRoot,
|
|
294
|
+
Player
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
declare type PlayerState = string;
|
|
299
|
+
|
|
300
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
301
|
+
/**
|
|
302
|
+
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
303
|
+
*/
|
|
304
|
+
init<T>(config: PluginConfig<T>, container: PlayerRoot, player: Player): void;
|
|
305
|
+
init(config: PluginConfig<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare type PluginConfig<T> = Config & T;
|
|
309
|
+
|
|
310
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
311
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare type SourceList = Array<SourceObj>;
|
|
315
|
+
|
|
316
|
+
declare type SourceObj = {
|
|
317
|
+
src?: SourceStr;
|
|
318
|
+
type?: string;
|
|
319
|
+
drm?: DRMSourceConfiguration;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
declare namespace Sources {
|
|
323
|
+
export {
|
|
324
|
+
SourceStr,
|
|
325
|
+
DRM_KEYSYSTEM,
|
|
326
|
+
SourceObj,
|
|
327
|
+
DRMSourceConfiguration,
|
|
328
|
+
SourceWith,
|
|
329
|
+
UnsafeSource,
|
|
330
|
+
SourceList,
|
|
331
|
+
DRMConfiguration,
|
|
332
|
+
DRMVendorImplementation
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
declare type SourceStr = string;
|
|
337
|
+
|
|
338
|
+
declare type SourceWith<T> = SourceObj & T;
|
|
339
|
+
|
|
340
|
+
declare type UnsafeSource = SourceStr | SourceObj | Array<SourceStr | SourceObj>;
|
|
341
|
+
|
|
342
|
+
declare interface VideoTrack {
|
|
343
|
+
name: string;
|
|
344
|
+
data: any;
|
|
345
|
+
default: boolean;
|
|
346
|
+
selected: boolean;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export { }
|
package/plugins/health.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e,DISPLAY:"display"});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e,DISPLAY:"display"});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function y(e){try{return!!new URL(e)}catch(e){return!1}}function m(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{try{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`flowplayer/${e} -- ${i}`,...o)}catch(e){console.warn(e)}};return i.log=i,i}const v=navigator;function E(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=v.connection)||void 0===n?void 0:n.downlink)||-1}function g(e,t){return async function(e,t){try{await fetch(e,{body:t,method:"POST",mode:"no-cors"})}catch(e){}}(e,JSON.stringify({events:t}))}const w="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),R=window,I=R._flowplayerTimekeeper||(R._flowplayerTimekeeper={});var O;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(O||(O={}));const D=e=>{switch(e){case!0:return O.ON;case!1:return O.OFF;default:return e}};function N(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}const T=[],A="https://ihi.flowplayer.com/v1/health/events";function b(e){if(e.suspended)return;const t=T.slice(0);T.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g(function(){try{return"undefined"==typeof window?A:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:A}catch(e){return A}}(),t))}async function S(e,t,n){const i=await U();T.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),T.length<10&&!n||b(e)}const L=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},U=async()=>{const e=Date.now();try{return{adjusted_time:e-await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(w)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}(),client_time:e}}catch(t){return{client_time:e}}},k=(e,t)=>Object.assign(e,{detail:t}),C=(e,{event:t,media_session_id:n,session_id:i,play_range_id:o})=>({event:t,media_session_id:n,session_id:i,play_range_id:o,device_id:e.deviceId(),version:"3.10.4-rc.3",commit:"67f705637e8ff10f2e500be6721424d93357ab2a",ima_sdk_version:L(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:E(e),page_url:N(),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),M=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function x(e,t,n,i){const o=C(t,e.eventInfo(n)),{before:s,after:r}=i;S(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,M(s),M(r)))}const F=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":F.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var P;function H(e){switch(e){case P.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case P.MEDIA_ERR_NETWORK:return"a network error occurred";case P.MEDIA_ERR_DECODE:return"unable to decode media content";case P.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case P.NO_INTERNET:return"no internet connection detected";case P.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(P||(P={}));const j=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},K=B();class Health{constructor(e,t){this.session_id=K,this.suspended=!1,this.logger=m("health",t.opts),this.media_session_id=B(),this.play_range_id=B(),this.analyticsLoop=setInterval(()=>b(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop)),t.on(l,()=>{this.play_range_id=B()});const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>b(this),2e3)}init(t,m,v){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(v),v.on("display",e=>{S(this,C(v,this.eventInfo(e.type)),!0)}),v.on("health:record",({detail:e})=>{const t=C(v,this.eventInfo(e.event));Object.assign(t,e.detail||{}),S(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{v.on(e,e=>{S(this,C(v,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{v.on(e,e=>{S(this,C(v,this.eventInfo(e.type)))})}),v.on("volumechange",j(800,e=>{const t=C(v,this.eventInfo(e.type));S(this,k(t,{volume:parseFloat(v.volume.toFixed(2)),muted:v.muted}))})),v.on("resize",j(800,e=>{const t=C(v,this.eventInfo(e.type));S(this,k(t,{height:m.clientHeight,width:m.clientWidth}))})),v.on("hls/failover",e=>{const t=C(v,this.eventInfo(e.type)),n=e.detail,{reason:i,from:o}=n;S(this,k(t,{reason:i,from:o}))}),v.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return x(this,v,e,t)}});let E=Date.now()+5e3;v.on("timeupdate",e=>{if(Date.now()<E)return;E=Date.now()+5e3;const t=C(v,this.eventInfo(e.type));var n;S(this,k(t,{duration:(n=v.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),v.addEventListener("error",e=>{const t=C(v,this.eventInfo(e.type)),n=e.error||v.error;if(!n)return S(this,t,!0);const i=n.code,o={error_message:n.message||H(i),error_code:i,error_stack:n.stack||""};return S(this,k(t,o),!0)}),v.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!y(v.original_src))return;if(!y(n))return;if(n==v.original_src)return;this.media_session_id=B();S(this,C(v,this.eventInfo(e.type))),b(this)}),v.on("visibilitychange",e=>{S(this,C(v,this.eventInfo(e.type))),b(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
|
package/plugins/ssai.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* https://github.com/lancedikson/bowser
|
|
5
5
|
* MIT License | (c) Dustin Diaz 2012-2015
|
|
6
6
|
* MIT License | (c) Denis Demchenko 2015-2019
|
|
7
|
-
*/const S=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return p}static get ENGINE_MAP(){return h}static get OS_MAP(){return g}static get PLATFORMS_MAP(){return m}}.parse(window.navigator.userAgent),{platform:_,os:M,browser:A}=S,E=e=>e&&e.toLowerCase();var U={rnd:Math.random().toString(36).substr(2,32),os:E(M.name+(M.versionName?" "+M.versionName:"")),device:E(_.type),browser:E(A.name),browser_version:(A&&A.version?A.version:"unknown").split(".").shift(),plugin_version:"3.10.4-rc.2"};const k="https://fp-eu-w1-aai.flowplayer.com/in",T="POST",R=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],P=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],O=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],F=c("ads/analytics"),q=RequestQueue.of(),B=(...e)=>Object.assign({},...e);class Analytics{constructor(e,t={}){this.emitter=e,this.metadata=B(U,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),F(this),this.wireup()}static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,B(e.metadata,t,{player_version:"3.10.4-rc.2"})),e}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,r=B(this.metadata,{event_type:e},s),i=Analytics.pluck_valid_keys(this,r),n=Analytics.ensure_required_keys(this,i);if(F(`Event[${e}]`,{payload:i,observation:s}),n.length)return F(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${n}`,i);RequestQueue.rpush(q,[k,T,i])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}var C;function D(e,t){var s;switch(t){case C.Preroll:return 0;case C.Postroll:return-1;default:return null===(s=e.ssai)||void 0===s?void 0:s.provider.getContentCurrentTime(e)}}function N(e,t,s){var r,i,n,a;const o=null===(r=t.ssai)||void 0===r?void 0:r.provider.getAdType(),d=null===(a=null===(n=null===(i=t.ssai)||void 0===i?void 0:i.provider)||void 0===n?void 0:n.src)||void 0===a?void 0:a.analyticsId,c={ad_break_time:D(t,o),ad_muted:t.muted,event_type:e};o&&Object.assign(c,{ad_type:o}),d&&Object.assign(c,{ad_tag_id:d}),s&&"duration"in s&&Object.assign(c,{ad_remaining_seconds:s.duration-s.currentTime,ad_duration_seconds:s.duration}),s&&"getAdId"in s&&Object.assign(c,{vast_ad_id:s.getAdId()}),t.emit("health:record",{event:"ads/"+e,detail:c}),t.emit(e,Object.assign(c,{data:s}))}function I(e,s){e.setState("ssai-ad-active",!0),t(e,e=>e.adProgress={currentTime:0,duration:s})}function x(e,s){var r;(null===(r=e.ssai)||void 0===r?void 0:r.state)&&t(e,e=>e.adProgress=s)}function L(e){if(!e.ssai)return;const s=e.ssai.state;e.setState("ssai-ad-active",!1),t(e,e=>delete e.adProgress),"number"==typeof s.snapbackTime&&(i(e,s.snapbackTime),delete s.snapbackTime)}!function(e){e.Preroll="preroll",e.Midroll="midroll",e.Postroll="postroll"}(C||(C={}));const Q=navigator.languages||[navigator.language];function j(e){const t=e.ssai.ui,s=new google.ima.dai.api.UiSettings,r=e.opt("lang")||function(){try{return Q.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().find(e=>!e.includes("-"))||"en";s.setLocale(r);const i=new google.ima.dai.api.StreamManager(e,t,s);return i.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.RESUMED,google.ima.dai.api.StreamEvent.Type.PAUSED,google.ima.dai.api.StreamEvent.Type.STARTED,google.ima.dai.api.StreamEvent.Type.COMPLETE,google.ima.dai.api.StreamEvent.Type.SKIPPED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,s){switch(s.type){case google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED:return function(e,t){var s,r;const i=t.getStreamData().streamId,n=e.ssai.provider;if(!i||!n.isPod)return;if(!n.isVod){const t=null===(s=n.src)||void 0===s?void 0:s.streamUrl;return t?e.setSrc(n.buildPodStreamURL(t,i)):console.error("streamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#create_a_simple_video_player_2")}const a=null===(r=n.src)||void 0===r?void 0:r.requestStreamUrl;if(!a)return console.error("requestStreamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#vod-pod-serving_1");a(e.ssai.streamManager,i)}(e,s);case google.ima.dai.api.StreamEvent.Type.RESUMED:return N("ad-resumed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.PAUSED:return N("ad-paused",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.COMPLETE:return N("ad-completed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.SKIPPED:return N("ad-skipped",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const s=t.getStreamData().url,r=e.ssai.provider;if(!s||r.isPod&&!r.isVod)return;e.setSrc(s)}(e,s);case google.ima.dai.api.StreamEvent.Type.STARTED:return e.ssai.provider.currentAd=s.getAd(),N("ad-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return I(e),N("ad-break-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return N(o,e,V(e,s)),L(e),e.ssai.provider.currentAd=void 0;case google.ima.dai.api.StreamEvent.Type.ERROR:return function(e,t){var s;const r=e.ssai.provider;if(null===(s=r.src)||void 0===s?void 0:s.backupStream)return e.setSrc(r.src.backupStream);e.emit("error",{message:t.getStreamData().errorMessage||"error loading stream"})}(e,s);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=V(e,s);return x(e,t.stream_data.adProgressData),N("ad-progress",e,t)}case google.ima.dai.api.StreamEvent.Type.CLICK:(function(e,t){if(!e.paused)e.togglePlay(!1)})(e)}}(e,0,t)},!1),e.on("ID3",({data:e})=>{const t=null==e?void 0:e.cue;if(!t)return;const s={},r=t.value;s[r.key]=r.data,i.onTimedMetadata(s)}),e.on("ssai:hls:metadata",e=>{var t;null===(t=e.detail)||void 0===t||t.samples.forEach(e=>i.processMetadata("ID3",e.data,e.pts))}),e.on("ssai:dash:metadata",e=>{const t=e.detail;if(!t)return;const s=t.event.messageData,r=t.event.calculatedPresentationTime;i.processMetadata("urn:google:dai:2018",s,r)}),i}function V(e,t){return{stream_data:t.getStreamData(),ad:e.ssai.provider.currentAd}}const z=c("ads/ima/sdk");var W;async function G(e,t){var s;const r=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(t?null==r?void 0:r.dai:r)return void z(":noop");const i=t?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":e._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(e){return new Promise((t,s)=>{let r=document.querySelector(`script[src='${e}']`);if(r)return K(r,t,s);r=document.createElement("script"),r.setAttribute("state",W.LOADING),K(r,t,s),r.src=e,document.head.appendChild(r)})}(i),void z(":loaded")}catch(e){z(":error "+e.message,e)}}function K(e,t,s){const r=e.getAttribute("state");if(r&&[W.ERROR,W.LOADED].includes(r))return t(void 0);e.addEventListener("load",()=>{e.setAttribute("state",W.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(t=>{e.addEventListener(t,()=>{e.setAttribute("state",W.ERROR),s("script failed to load")},{once:!0})})}!function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(W||(W={}));const H=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends H.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=r(this.video);i(this.video,e+t/1e3)}I(this.video,e.getStart()),N("ad-break-started",this.video)}onAdvertBreakEnd(){L(this.video),N(o,this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function $(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const s=e.getPayload();if(s.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=s;const e=new EventObserver(t);s.addAnalyticObserver(e),t.setSrc({src:s.getPlaybackUrl()}),setInterval(()=>{const e=1e3*r(t);s.onPlayheadUpdate(e),function(e,t,s){const r=e.getCurrentAdBreak();if(!r)return;const i={currentTime:s-r.getStart(),duration:r.getDuration()};x(t,i),N("ad-progress",t,{stream_data:i})}(s,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+s.getResultCode())})}var Z=Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&(!function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return r(e)},set:function(t){var s;if(e.ssai){if(e.ssai.state.adProgress)return;return null===(s=e.ssai.provider)||void 0===s?void 0:s.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return a(e)},set:function(){}})}(t),Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}()))},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&$(t.src,e)},getContentCurrentTime:function(e){const t=r(e),s=e.ssai.session;return s?s.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const s=e.ssai.session;return i(e,s?s.getPlayheadForContentPosition(1e3*t)/1e3:t)},getContentDuration:function(e){const t=e.ssai.session,s=a(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:s},getAdType:function(){},getPreviousActiveAdStart:function(e,t){const s=e.ssai.session;if(!s)return;const r=s.getAdBreaks();let i;const n=1e3*t;return r.forEach(e=>{void 0===i&&e.getStart()<n&&e.isActive()&&(i=e)}),void 0!==i?i.getStart()/1e3:void 0}});const X=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?r:i})(e._customElements,t))(e),Y=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class SSAIAdUi extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-ui",this.append(...this.player.createComponents("flowplayer-ssai-indicator","flowplayer-ssai-timeline","flowplayer-ssai-controls"))}}class SSAITimeline extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-timeline";const t=document.createElement("div");t.className="fp-ssai-progress",this.append(t),this.player.on(o,()=>{t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>this.style.setProperty(e,"0"))}),this.player.on("ad-progress",e=>{var s,r,i;const n=null===(i=null===(r=null===(s=e.detail)||void 0===s?void 0:s.data)||void 0===r?void 0:r.stream_data)||void 0===i?void 0:i.adProgressData;if(!n)return;const a=n.currentTime/n.duration*100,o=t.style.getPropertyValue("--ssai-percent-complete");t.classList.remove("go"),t.style.setProperty("--ssai-percent-previous",o),t.style.setProperty("--ssai-percent-complete",a.toFixed(3)),t.classList.add("go")})}}function J(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}class SSAIControls extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-controls",this.createLeftZone(),this.createRightZone()}createRightZone(){const e=document.createElement("div");e.className="fp-ssai-right-zone",e.append(...this.player.createComponents("flowplayer-volume-control"),...this.fsIcons()),this.append(e)}createLeftZone(){const e=document.createElement("div");e.className="fp-ssai-left-zone",e.append(...this.player.createComponents("flowplayer-control-buttons"),this.remainingTimeComponent()),this.append(e)}fsIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(e=>(e.onclick=()=>this.player.toggleFullScreen(),e))}remainingTimeComponent(){const e=document.createElement("div");return e.className="fp-ssai-remaining",this.player.on("ad-progress",t=>{var s,r;const i=null===(r=null===(s=t.detail.data)||void 0===s?void 0:s.stream_data)||void 0===r?void 0:r.adProgressData;i&&(e.textContent=function(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const s=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,s>=1?(r-=60*s,t+s+":"+J(r)+":"+J(e)):t+J(r)+":"+J(e)}(i.duration-i.currentTime))}),e}}class SSAIAdIndicator extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-indicator",this.player.on("ad-started",e=>{var t,s,r;const i=null===(r=null===(s=null===(t=e.detail)||void 0===t?void 0:t.data)||void 0===s?void 0:s.ad)||void 0===r?void 0:r.getAdPodInfo();i&&(this.textContent=`${this.player.i18n("ads.indicator","ADS")} ${i.getAdPosition()} / ${i.getTotalAds()}`)})}}const ee=[Z,new class Dai{async init(e,t){var s,r;if(t.ssai)return this.make_analytics(t),await G(t,!0),(null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai)?void 0:console.warn("google.ima.dai unavailable")}async onload(e,t){var s,r,i;if(await G(e,!0),null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai){if((null===(i=e.ssai)||void 0===i?void 0:i.streamManager)||(e.ssai.streamManager=j(e)),this.src=t,this.isPod=!!t.networkCode,this.isVod=!(t.assetKey||t.customAssetKey),this.isPod)return this.requestPodStream(e.ssai.streamManager,t);this.requestStream(e.ssai.streamManager,t)}}make_analytics(e){const t=Analytics.of(e,{required_keys:P,events:R,optional_keys:O});e.on("config",()=>{var s;return Analytics.mergeMetadata(t,null===(s=e.opts)||void 0===s?void 0:s.metadata)})}exists(){return!0}getAdType(){if(this.currentAd)switch(this.currentAd.getAdPodInfo().getPodIndex()){case 0:return C.Preroll;case-1:return C.Postroll;case-2:return;default:return C.Midroll}}getContentCurrentTime(e){const t=e.ssai.streamManager,s=e.currentTime;return t?t.contentTimeForStreamTime(s):s}setContentCurrentTime(e,t){}getContentDuration(e){const t=e.ssai.streamManager,s=e.duration;return t?t.contentTimeForStreamTime(s):s}getPreviousActiveAdStart(e,t){const s=e.ssai.streamManager.previousCuePointForStreamTime(t);if(s&&!s.played)return s.start}srcIsValid(e){return"google/dai"==e.type&&!!(e.videoId&&e.contentSourceId||e.assetKey||e.networkCode)}requestStream(e,t){const s=this.isVod?new google.ima.dai.api.VODStreamRequest:new google.ima.dai.api.LiveStreamRequest;e.requestStream(Object.assign(s,t))}requestPodStream(e,t){const s=this.isVod?new google.ima.dai.api.PodVodStreamRequest:new google.ima.dai.api.PodStreamRequest;e.requestStream(Object.assign(s,t))}buildPodStreamURL(e,t){return e.replace("[[STREAMID]]",t)}}];class Ssai{constructor(e){this.umd=e,Y(e,"flowplayer-ssai-ui",SSAIAdUi),Y(e,"flowplayer-ssai-timeline",SSAITimeline),Y(e,"flowplayer-ssai-controls",SSAIControls),Y(e,"flowplayer-ssai-indicator",SSAIAdIndicator)}init(e,t,s){ee.forEach(e=>{if(s.ssai||!e.exists())return;const n=X(s,"flowplayer-ssai-ui");t.append(n),s.ssai={provider:e,ui:n,state:{snapback:!1}},e.init(t,s),s.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:s}=e.ssai;if(s.snapback)return s.snapback=!1;const n=r(e),a=t.getPreviousActiveAdStart(e,n);void 0!==a&&(s.snapback=!0,s.snapbackTime=n,i(e,a))}(s))})}onload(e,t,s,r){var i;(null===(i=s.ssai)||void 0===i?void 0:i.provider)&&s.ssai.provider.onload(s,r)}wants(e,t,s){let r=!1;return ee.forEach(e=>{if(!r&&e.exists()&&e.srcIsValid(t))return r=!0}),r}}return Ssai.events=d,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Ssai),Ssai}));
|
|
7
|
+
*/const S=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return p}static get ENGINE_MAP(){return h}static get OS_MAP(){return g}static get PLATFORMS_MAP(){return m}}.parse(window.navigator.userAgent),{platform:_,os:M,browser:A}=S,E=e=>e&&e.toLowerCase();var U={rnd:Math.random().toString(36).substr(2,32),os:E(M.name+(M.versionName?" "+M.versionName:"")),device:E(_.type),browser:E(A.name),browser_version:(A&&A.version?A.version:"unknown").split(".").shift(),plugin_version:"3.10.4-rc.3"};const k="https://fp-eu-w1-aai.flowplayer.com/in",T="POST",R=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],P=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],O=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],F=c("ads/analytics"),q=RequestQueue.of(),B=(...e)=>Object.assign({},...e);class Analytics{constructor(e,t={}){this.emitter=e,this.metadata=B(U,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),F(this),this.wireup()}static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,B(e.metadata,t,{player_version:"3.10.4-rc.3"})),e}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,r=B(this.metadata,{event_type:e},s),i=Analytics.pluck_valid_keys(this,r),n=Analytics.ensure_required_keys(this,i);if(F(`Event[${e}]`,{payload:i,observation:s}),n.length)return F(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${n}`,i);RequestQueue.rpush(q,[k,T,i])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}var C;function D(e,t){var s;switch(t){case C.Preroll:return 0;case C.Postroll:return-1;default:return null===(s=e.ssai)||void 0===s?void 0:s.provider.getContentCurrentTime(e)}}function N(e,t,s){var r,i,n,a;const o=null===(r=t.ssai)||void 0===r?void 0:r.provider.getAdType(),d=null===(a=null===(n=null===(i=t.ssai)||void 0===i?void 0:i.provider)||void 0===n?void 0:n.src)||void 0===a?void 0:a.analyticsId,c={ad_break_time:D(t,o),ad_muted:t.muted,event_type:e};o&&Object.assign(c,{ad_type:o}),d&&Object.assign(c,{ad_tag_id:d}),s&&"duration"in s&&Object.assign(c,{ad_remaining_seconds:s.duration-s.currentTime,ad_duration_seconds:s.duration}),s&&"getAdId"in s&&Object.assign(c,{vast_ad_id:s.getAdId()}),t.emit("health:record",{event:"ads/"+e,detail:c}),t.emit(e,Object.assign(c,{data:s}))}function I(e,s){e.setState("ssai-ad-active",!0),t(e,e=>e.adProgress={currentTime:0,duration:s})}function x(e,s){var r;(null===(r=e.ssai)||void 0===r?void 0:r.state)&&t(e,e=>e.adProgress=s)}function L(e){if(!e.ssai)return;const s=e.ssai.state;e.setState("ssai-ad-active",!1),t(e,e=>delete e.adProgress),"number"==typeof s.snapbackTime&&(i(e,s.snapbackTime),delete s.snapbackTime)}!function(e){e.Preroll="preroll",e.Midroll="midroll",e.Postroll="postroll"}(C||(C={}));const Q=navigator.languages||[navigator.language];function j(e){const t=e.ssai.ui,s=new google.ima.dai.api.UiSettings,r=e.opt("lang")||function(){try{return Q.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().find(e=>!e.includes("-"))||"en";s.setLocale(r);const i=new google.ima.dai.api.StreamManager(e,t,s);return i.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.RESUMED,google.ima.dai.api.StreamEvent.Type.PAUSED,google.ima.dai.api.StreamEvent.Type.STARTED,google.ima.dai.api.StreamEvent.Type.COMPLETE,google.ima.dai.api.StreamEvent.Type.SKIPPED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,s){switch(s.type){case google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED:return function(e,t){var s,r;const i=t.getStreamData().streamId,n=e.ssai.provider;if(!i||!n.isPod)return;if(!n.isVod){const t=null===(s=n.src)||void 0===s?void 0:s.streamUrl;return t?e.setSrc(n.buildPodStreamURL(t,i)):console.error("streamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#create_a_simple_video_player_2")}const a=null===(r=n.src)||void 0===r?void 0:r.requestStreamUrl;if(!a)return console.error("requestStreamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#vod-pod-serving_1");a(e.ssai.streamManager,i)}(e,s);case google.ima.dai.api.StreamEvent.Type.RESUMED:return N("ad-resumed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.PAUSED:return N("ad-paused",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.COMPLETE:return N("ad-completed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.SKIPPED:return N("ad-skipped",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const s=t.getStreamData().url,r=e.ssai.provider;if(!s||r.isPod&&!r.isVod)return;e.setSrc(s)}(e,s);case google.ima.dai.api.StreamEvent.Type.STARTED:return e.ssai.provider.currentAd=s.getAd(),N("ad-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return I(e),N("ad-break-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return N(o,e,V(e,s)),L(e),e.ssai.provider.currentAd=void 0;case google.ima.dai.api.StreamEvent.Type.ERROR:return function(e,t){var s;const r=e.ssai.provider;if(null===(s=r.src)||void 0===s?void 0:s.backupStream)return e.setSrc(r.src.backupStream);e.emit("error",{message:t.getStreamData().errorMessage||"error loading stream"})}(e,s);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=V(e,s);return x(e,t.stream_data.adProgressData),N("ad-progress",e,t)}case google.ima.dai.api.StreamEvent.Type.CLICK:(function(e,t){if(!e.paused)e.togglePlay(!1)})(e)}}(e,0,t)},!1),e.on("ID3",({data:e})=>{const t=null==e?void 0:e.cue;if(!t)return;const s={},r=t.value;s[r.key]=r.data,i.onTimedMetadata(s)}),e.on("ssai:hls:metadata",e=>{var t;null===(t=e.detail)||void 0===t||t.samples.forEach(e=>i.processMetadata("ID3",e.data,e.pts))}),e.on("ssai:dash:metadata",e=>{const t=e.detail;if(!t)return;const s=t.event.messageData,r=t.event.calculatedPresentationTime;i.processMetadata("urn:google:dai:2018",s,r)}),i}function V(e,t){return{stream_data:t.getStreamData(),ad:e.ssai.provider.currentAd}}const z=c("ads/ima/sdk");var W;async function G(e,t){var s;const r=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(t?null==r?void 0:r.dai:r)return void z(":noop");const i=t?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":e._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(e){return new Promise((t,s)=>{let r=document.querySelector(`script[src='${e}']`);if(r)return K(r,t,s);r=document.createElement("script"),r.setAttribute("state",W.LOADING),K(r,t,s),r.src=e,document.head.appendChild(r)})}(i),void z(":loaded")}catch(e){z(":error "+e.message,e)}}function K(e,t,s){const r=e.getAttribute("state");if(r&&[W.ERROR,W.LOADED].includes(r))return t(void 0);e.addEventListener("load",()=>{e.setAttribute("state",W.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(t=>{e.addEventListener(t,()=>{e.setAttribute("state",W.ERROR),s("script failed to load")},{once:!0})})}!function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(W||(W={}));const H=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends H.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=r(this.video);i(this.video,e+t/1e3)}I(this.video,e.getStart()),N("ad-break-started",this.video)}onAdvertBreakEnd(){L(this.video),N(o,this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function $(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const s=e.getPayload();if(s.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=s;const e=new EventObserver(t);s.addAnalyticObserver(e),t.setSrc({src:s.getPlaybackUrl()}),setInterval(()=>{const e=1e3*r(t);s.onPlayheadUpdate(e),function(e,t,s){const r=e.getCurrentAdBreak();if(!r)return;const i={currentTime:s-r.getStart(),duration:r.getDuration()};x(t,i),N("ad-progress",t,{stream_data:i})}(s,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+s.getResultCode())})}var Z=Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&(!function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return r(e)},set:function(t){var s;if(e.ssai){if(e.ssai.state.adProgress)return;return null===(s=e.ssai.provider)||void 0===s?void 0:s.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return a(e)},set:function(){}})}(t),Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}()))},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&$(t.src,e)},getContentCurrentTime:function(e){const t=r(e),s=e.ssai.session;return s?s.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const s=e.ssai.session;return i(e,s?s.getPlayheadForContentPosition(1e3*t)/1e3:t)},getContentDuration:function(e){const t=e.ssai.session,s=a(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:s},getAdType:function(){},getPreviousActiveAdStart:function(e,t){const s=e.ssai.session;if(!s)return;const r=s.getAdBreaks();let i;const n=1e3*t;return r.forEach(e=>{void 0===i&&e.getStart()<n&&e.isActive()&&(i=e)}),void 0!==i?i.getStart()/1e3:void 0}});const X=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?r:i})(e._customElements,t))(e),Y=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class SSAIAdUi extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-ui",this.append(...this.player.createComponents("flowplayer-ssai-indicator","flowplayer-ssai-timeline","flowplayer-ssai-controls"))}}class SSAITimeline extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-timeline";const t=document.createElement("div");t.className="fp-ssai-progress",this.append(t),this.player.on(o,()=>{t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>this.style.setProperty(e,"0"))}),this.player.on("ad-progress",e=>{var s,r,i;const n=null===(i=null===(r=null===(s=e.detail)||void 0===s?void 0:s.data)||void 0===r?void 0:r.stream_data)||void 0===i?void 0:i.adProgressData;if(!n)return;const a=n.currentTime/n.duration*100,o=t.style.getPropertyValue("--ssai-percent-complete");t.classList.remove("go"),t.style.setProperty("--ssai-percent-previous",o),t.style.setProperty("--ssai-percent-complete",a.toFixed(3)),t.classList.add("go")})}}function J(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}class SSAIControls extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-controls",this.createLeftZone(),this.createRightZone()}createRightZone(){const e=document.createElement("div");e.className="fp-ssai-right-zone",e.append(...this.player.createComponents("flowplayer-volume-control"),...this.fsIcons()),this.append(e)}createLeftZone(){const e=document.createElement("div");e.className="fp-ssai-left-zone",e.append(...this.player.createComponents("flowplayer-control-buttons"),this.remainingTimeComponent()),this.append(e)}fsIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(e=>(e.onclick=()=>this.player.toggleFullScreen(),e))}remainingTimeComponent(){const e=document.createElement("div");return e.className="fp-ssai-remaining",this.player.on("ad-progress",t=>{var s,r;const i=null===(r=null===(s=t.detail.data)||void 0===s?void 0:s.stream_data)||void 0===r?void 0:r.adProgressData;i&&(e.textContent=function(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const s=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,s>=1?(r-=60*s,t+s+":"+J(r)+":"+J(e)):t+J(r)+":"+J(e)}(i.duration-i.currentTime))}),e}}class SSAIAdIndicator extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-indicator",this.player.on("ad-started",e=>{var t,s,r;const i=null===(r=null===(s=null===(t=e.detail)||void 0===t?void 0:t.data)||void 0===s?void 0:s.ad)||void 0===r?void 0:r.getAdPodInfo();i&&(this.textContent=`${this.player.i18n("ads.indicator","ADS")} ${i.getAdPosition()} / ${i.getTotalAds()}`)})}}const ee=[Z,new class Dai{async init(e,t){var s,r;if(t.ssai)return this.make_analytics(t),await G(t,!0),(null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai)?void 0:console.warn("google.ima.dai unavailable")}async onload(e,t){var s,r,i;if(await G(e,!0),null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai){if((null===(i=e.ssai)||void 0===i?void 0:i.streamManager)||(e.ssai.streamManager=j(e)),this.src=t,this.isPod=!!t.networkCode,this.isVod=!(t.assetKey||t.customAssetKey),this.isPod)return this.requestPodStream(e.ssai.streamManager,t);this.requestStream(e.ssai.streamManager,t)}}make_analytics(e){const t=Analytics.of(e,{required_keys:P,events:R,optional_keys:O});e.on("config",()=>{var s;return Analytics.mergeMetadata(t,null===(s=e.opts)||void 0===s?void 0:s.metadata)})}exists(){return!0}getAdType(){if(this.currentAd)switch(this.currentAd.getAdPodInfo().getPodIndex()){case 0:return C.Preroll;case-1:return C.Postroll;case-2:return;default:return C.Midroll}}getContentCurrentTime(e){const t=e.ssai.streamManager,s=e.currentTime;return t?t.contentTimeForStreamTime(s):s}setContentCurrentTime(e,t){}getContentDuration(e){const t=e.ssai.streamManager,s=e.duration;return t?t.contentTimeForStreamTime(s):s}getPreviousActiveAdStart(e,t){const s=e.ssai.streamManager.previousCuePointForStreamTime(t);if(s&&!s.played)return s.start}srcIsValid(e){return"google/dai"==e.type&&!!(e.videoId&&e.contentSourceId||e.assetKey||e.networkCode)}requestStream(e,t){const s=this.isVod?new google.ima.dai.api.VODStreamRequest:new google.ima.dai.api.LiveStreamRequest;e.requestStream(Object.assign(s,t))}requestPodStream(e,t){const s=this.isVod?new google.ima.dai.api.PodVodStreamRequest:new google.ima.dai.api.PodStreamRequest;e.requestStream(Object.assign(s,t))}buildPodStreamURL(e,t){return e.replace("[[STREAMID]]",t)}}];class Ssai{constructor(e){this.umd=e,Y(e,"flowplayer-ssai-ui",SSAIAdUi),Y(e,"flowplayer-ssai-timeline",SSAITimeline),Y(e,"flowplayer-ssai-controls",SSAIControls),Y(e,"flowplayer-ssai-indicator",SSAIAdIndicator)}init(e,t,s){ee.forEach(e=>{if(s.ssai||!e.exists())return;const n=X(s,"flowplayer-ssai-ui");t.append(n),s.ssai={provider:e,ui:n,state:{snapback:!1}},e.init(t,s),s.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:s}=e.ssai;if(s.snapback)return s.snapback=!1;const n=r(e),a=t.getPreviousActiveAdStart(e,n);void 0!==a&&(s.snapback=!0,s.snapbackTime=n,i(e,a))}(s))})}onload(e,t,s,r){var i;(null===(i=s.ssai)||void 0===i?void 0:i.provider)&&s.ssai.provider.onload(s,r)}wants(e,t,s){let r=!1;return ee.forEach(e=>{if(!r&&e.exists()&&e.srcIsValid(t))return r=!0}),r}}return Ssai.events=d,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Ssai),Ssai}));
|
package/util/loader.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type AnyPlugin = Plugin_2 | Loader
|
|
3
|
+
declare type AnyPlugin<PluginOwnConfig extends KeyValue> = Plugin_2<PluginOwnConfig> | Loader<PluginOwnConfig>;
|
|
4
|
+
|
|
5
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [infer Current, ...infer Remaining] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
6
|
|
|
5
7
|
declare type BitOpts = number;
|
|
6
8
|
|
|
@@ -81,7 +83,7 @@ declare type CustomConfig<T> = Config & T;
|
|
|
81
83
|
* adds support for asynchronous plugin loading`
|
|
82
84
|
* issue/127
|
|
83
85
|
*/
|
|
84
|
-
export declare function define(root: any, plugin:
|
|
86
|
+
export declare function define<SpecificPluginCtor extends PluginCtor>(root: any, plugin: SpecificPluginCtor): SpecificPluginCtor;
|
|
85
87
|
|
|
86
88
|
declare type DeviceId = string;
|
|
87
89
|
|
|
@@ -153,12 +155,12 @@ declare namespace Flowplayer {
|
|
|
153
155
|
|
|
154
156
|
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
155
157
|
|
|
156
|
-
declare interface FlowplayerUMD {
|
|
157
|
-
(selector: string, config?:
|
|
158
|
+
declare interface FlowplayerUMD<ConfigWithPlugins extends Config = Config> {
|
|
159
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
158
160
|
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
159
|
-
(element: HTMLElement, config?:
|
|
161
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
160
162
|
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
161
|
-
(...plugins:
|
|
163
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMD<CustomConfig<ArrayToIntersection<MapToConfigs<PluginCtors>>>>;
|
|
162
164
|
instances: Player[];
|
|
163
165
|
extensions: PluginCtor[];
|
|
164
166
|
events: Record<string, string>;
|
|
@@ -201,12 +203,16 @@ declare type JSONPlayer = any;
|
|
|
201
203
|
|
|
202
204
|
declare type KeyValue = Record<string, any>;
|
|
203
205
|
|
|
204
|
-
declare interface Loader extends Plugin_2 {
|
|
206
|
+
declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Plugin_2<PluginOwnConfig> {
|
|
205
207
|
onload<T = KeyValue>(config: PluginConfig<T>, root: PlayerRoot, video: Player, src?: SourceObj): void;
|
|
206
208
|
wants<S = SourceObj, T = KeyValue>(srcString: SourceStr, srcObj: S, config: PluginConfig<T>): boolean;
|
|
207
209
|
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
208
210
|
}
|
|
209
211
|
|
|
212
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
213
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
214
|
+
};
|
|
215
|
+
|
|
210
216
|
export declare function modules(): any;
|
|
211
217
|
|
|
212
218
|
declare interface Player extends HTMLVideoElement {
|
|
@@ -275,18 +281,18 @@ declare namespace Players {
|
|
|
275
281
|
|
|
276
282
|
declare type PlayerState = string;
|
|
277
283
|
|
|
278
|
-
declare interface Plugin_2 {
|
|
284
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
279
285
|
/**
|
|
280
286
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
281
287
|
*/
|
|
282
288
|
init<T>(config: PluginConfig<T>, container: PlayerRoot, player: Player): void;
|
|
283
|
-
init(config:
|
|
289
|
+
init(config: PluginConfig<PluginOwnConfig>, container: PlayerRoot, player: Player): void;
|
|
284
290
|
}
|
|
285
291
|
|
|
286
292
|
declare type PluginConfig<T> = Config & T;
|
|
287
293
|
|
|
288
|
-
declare interface PluginCtor {
|
|
289
|
-
new (umd: FlowplayerUMD, player: Player): AnyPlugin
|
|
294
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
295
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
export declare function root(): {};
|