@flowplayer/player 3.11.2-rc.2 → 3.11.2-rc.4
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 +1 -1
- package/package.json +1 -1
- package/plugins/ads.d.ts +5 -432
- package/plugins/ads.js +1 -1
- package/plugins/airplay.d.ts +7 -60
- package/plugins/airplay.js +1 -1
- package/plugins/analytics.d.ts +74 -53
- package/plugins/analytics.js +1 -1
- package/plugins/asel.d.ts +5 -43
- package/plugins/asel.js +1 -1
- package/plugins/audio.d.ts +1 -23
- package/plugins/chapters.d.ts +5 -74
- package/plugins/chapters.js +1 -1
- package/plugins/chromecast.d.ts +20 -82
- package/plugins/consent.d.ts +3 -47
- package/plugins/context-menu.d.ts +75 -19
- package/plugins/context-menu.js +1 -1
- package/plugins/cuepoints.d.ts +2 -21
- package/plugins/dash.d.ts +5 -44
- package/plugins/drm.d.ts +74 -80
- package/plugins/drm.js +1 -1
- package/plugins/endscreen.d.ts +7 -53
- package/plugins/fas.d.ts +5 -46
- package/plugins/fas.js +1 -1
- package/plugins/ga4.d.ts +30 -61
- package/plugins/ga4.js +1 -1
- package/plugins/gemius.d.ts +7 -45
- package/plugins/google-analytics.d.ts +30 -63
- package/plugins/google-analytics.js +1 -1
- package/plugins/health.d.ts +5 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.d.ts +81 -15
- package/plugins/hls.js +1 -1
- package/plugins/id3.d.ts +74 -13
- package/plugins/id3.js +1 -1
- package/plugins/iframe.d.ts +2 -18
- package/plugins/iframe.js +1 -1
- package/plugins/keyboard.d.ts +75 -5
- package/plugins/keyboard.js +1 -1
- package/plugins/media-session.d.ts +74 -4
- package/plugins/media-session.js +1 -1
- package/plugins/message.d.ts +74 -8
- package/plugins/message.js +1 -1
- package/plugins/ovp.d.ts +22 -44
- package/plugins/ovp.js +1 -1
- package/plugins/playlist.d.ts +5 -46
- package/plugins/playlist.js +1 -1
- package/plugins/preview.d.ts +86 -50
- package/plugins/qsel.d.ts +3 -26
- package/plugins/qul.d.ts +78 -29
- package/plugins/rts.d.ts +68 -82
- package/plugins/rts.js +1 -1
- package/plugins/share.d.ts +3 -37
- package/plugins/share.js +1 -1
- package/plugins/speed.d.ts +1 -10
- package/plugins/ssai.d.ts +2 -47
- package/plugins/ssai.js +1 -1
- package/plugins/subtitles.d.ts +11 -13
- package/plugins/subtitles.js +1 -1
- package/plugins/thumbnails.d.ts +5 -50
- package/plugins/thumbnails.js +1 -1
- package/plugins/tizen.d.ts +7 -118
- package/plugins/tizen.js +1 -1
- package/plugins/vtsel.d.ts +3 -26
- package/plugins/vtsel.js +1 -1
- package/plugins/webos.d.ts +7 -118
- package/plugins/webos.js +1 -1
- package/util/loader.d.ts +1 -1
package/plugins/qul.d.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
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 enum AutoplayOpts {
|
|
8
|
+
OFF = 0,
|
|
9
|
+
ON = 1,
|
|
10
|
+
AUDIO_REQUIRED = 2
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
declare type BitOpts = number;
|
|
4
14
|
|
|
15
|
+
declare type Component = {
|
|
16
|
+
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
17
|
+
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare interface Components {
|
|
21
|
+
render(key: string, args: any[]): void;
|
|
22
|
+
remove(key: string, args: any[]): void;
|
|
23
|
+
put(key: string, args: Component): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
declare interface Config {
|
|
6
27
|
src?: UnsafeSource;
|
|
7
28
|
preload?: "none" | "metadata" | "auto";
|
|
@@ -52,21 +73,19 @@ declare interface Config {
|
|
|
52
73
|
seconds_to_dvr?: number;
|
|
53
74
|
}
|
|
54
75
|
|
|
55
|
-
declare namespace Configs {
|
|
56
|
-
export {
|
|
57
|
-
BitOpts,
|
|
58
|
-
FlowplayerCustomElementRegistry,
|
|
59
|
-
Config,
|
|
60
|
-
CustomConfig,
|
|
61
|
-
PluginConfig
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
declare type ConfigWith<T> = Configs.Config & T;
|
|
66
|
-
|
|
67
76
|
declare type CustomConfig<T> = Config & T;
|
|
68
77
|
|
|
69
|
-
declare const _default:
|
|
78
|
+
declare const _default: PluginCtor< {
|
|
79
|
+
hls?: {
|
|
80
|
+
native?: boolean | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
qul?: {
|
|
83
|
+
token: string;
|
|
84
|
+
device_id?: string | undefined;
|
|
85
|
+
dId?: string | undefined;
|
|
86
|
+
interval?: number | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
}>;
|
|
70
89
|
export default _default;
|
|
71
90
|
|
|
72
91
|
declare type DeviceId = string;
|
|
@@ -96,6 +115,39 @@ declare type DRMVendorImplementation = {
|
|
|
96
115
|
|
|
97
116
|
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
98
117
|
|
|
118
|
+
declare interface FlowplayerUMD extends FlowplayerUMDBase {
|
|
119
|
+
(selector: string, config?: Config): Player;
|
|
120
|
+
(element: HTMLElement, config?: Config): Player;
|
|
121
|
+
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
122
|
+
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
123
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMDWithPlugins<CustomConfig<MergeConfigs<PluginCtors>>>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare interface FlowplayerUMDBase {
|
|
127
|
+
instances: Player[];
|
|
128
|
+
extensions: PluginCtor[];
|
|
129
|
+
events: Record<string, string>;
|
|
130
|
+
ads?: {
|
|
131
|
+
events: Record<string, string>;
|
|
132
|
+
};
|
|
133
|
+
states: Record<string, string>;
|
|
134
|
+
quality: typeof QualityOpts;
|
|
135
|
+
commit: string;
|
|
136
|
+
version: string;
|
|
137
|
+
customElements: FlowplayerCustomElementRegistry;
|
|
138
|
+
defaultElements: Record<string, string>;
|
|
139
|
+
components: Components;
|
|
140
|
+
support: any;
|
|
141
|
+
autoplay: typeof AutoplayOpts;
|
|
142
|
+
jwt: any;
|
|
143
|
+
loaders: any;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config> extends FlowplayerUMDBase {
|
|
147
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
148
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
149
|
+
}
|
|
150
|
+
|
|
99
151
|
declare interface FPEvent<T> extends CustomEvent<T> {
|
|
100
152
|
/**
|
|
101
153
|
* @deprecated
|
|
@@ -115,6 +167,12 @@ declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Pl
|
|
|
115
167
|
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
116
168
|
}
|
|
117
169
|
|
|
170
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
171
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToConfigs<Arr>>;
|
|
175
|
+
|
|
118
176
|
declare interface Player extends HTMLVideoElement {
|
|
119
177
|
renderPlugin: (pluginContainer: HTMLElement) => void;
|
|
120
178
|
toggleDisable: (flag: boolean) => void;
|
|
@@ -179,23 +237,14 @@ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
|
179
237
|
|
|
180
238
|
declare type PluginConfig<T> = Config & T;
|
|
181
239
|
|
|
182
|
-
declare
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
186
|
-
qul?: {
|
|
187
|
-
token: string;
|
|
188
|
-
device_id?: string;
|
|
189
|
-
dId?: string;
|
|
190
|
-
interval?: number;
|
|
191
|
-
};
|
|
192
|
-
}>;
|
|
240
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
241
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
242
|
+
}
|
|
193
243
|
|
|
194
|
-
declare
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
init(config: QULConfig, root: PlayerRoot, player: Player): void;
|
|
244
|
+
declare enum QualityOpts {
|
|
245
|
+
LOW = 1,
|
|
246
|
+
MEDIUM = 2,
|
|
247
|
+
HIGH = 4
|
|
199
248
|
}
|
|
200
249
|
|
|
201
250
|
declare type SourceObj = {
|
package/plugins/rts.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
|
-
|
|
3
|
-
|
|
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 enum AutoplayOpts {
|
|
8
|
+
OFF = 0,
|
|
9
|
+
ON = 1,
|
|
10
|
+
AUDIO_REQUIRED = 2
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
declare type BitOpts = number;
|
|
6
14
|
|
|
15
|
+
declare type Component = {
|
|
16
|
+
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
17
|
+
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare interface Components {
|
|
21
|
+
render(key: string, args: any[]): void;
|
|
22
|
+
remove(key: string, args: any[]): void;
|
|
23
|
+
put(key: string, args: Component): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
7
26
|
declare interface Config {
|
|
8
27
|
src?: UnsafeSource;
|
|
9
28
|
preload?: "none" | "metadata" | "auto";
|
|
@@ -54,6 +73,11 @@ declare interface Config {
|
|
|
54
73
|
seconds_to_dvr?: number;
|
|
55
74
|
}
|
|
56
75
|
|
|
76
|
+
declare type CustomConfig<T> = Config & T;
|
|
77
|
+
|
|
78
|
+
declare const _default: PluginCtor<KeyValue>;
|
|
79
|
+
export default _default;
|
|
80
|
+
|
|
57
81
|
declare type DeviceId = string;
|
|
58
82
|
|
|
59
83
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
|
@@ -79,14 +103,40 @@ declare type DRMVendorImplementation = {
|
|
|
79
103
|
}, cb: (license_data: Uint8Array) => void) => void;
|
|
80
104
|
};
|
|
81
105
|
|
|
82
|
-
declare
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
107
|
+
|
|
108
|
+
declare interface FlowplayerUMD extends FlowplayerUMDBase {
|
|
109
|
+
(selector: string, config?: Config): Player;
|
|
110
|
+
(element: HTMLElement, config?: Config): Player;
|
|
111
|
+
<T>(selector: string, config?: CustomConfig<T>): Player;
|
|
112
|
+
<T>(element: HTMLElement, config?: CustomConfig<T>): Player;
|
|
113
|
+
<PluginCtors extends PluginCtor[]>(...plugins: PluginCtors): FlowplayerUMDWithPlugins<CustomConfig<MergeConfigs<PluginCtors>>>;
|
|
87
114
|
}
|
|
88
115
|
|
|
89
|
-
declare
|
|
116
|
+
declare interface FlowplayerUMDBase {
|
|
117
|
+
instances: Player[];
|
|
118
|
+
extensions: PluginCtor[];
|
|
119
|
+
events: Record<string, string>;
|
|
120
|
+
ads?: {
|
|
121
|
+
events: Record<string, string>;
|
|
122
|
+
};
|
|
123
|
+
states: Record<string, string>;
|
|
124
|
+
quality: typeof QualityOpts;
|
|
125
|
+
commit: string;
|
|
126
|
+
version: string;
|
|
127
|
+
customElements: FlowplayerCustomElementRegistry;
|
|
128
|
+
defaultElements: Record<string, string>;
|
|
129
|
+
components: Components;
|
|
130
|
+
support: any;
|
|
131
|
+
autoplay: typeof AutoplayOpts;
|
|
132
|
+
jwt: any;
|
|
133
|
+
loaders: any;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config> extends FlowplayerUMDBase {
|
|
137
|
+
(selector: string, config?: ConfigWithPlugins): Player;
|
|
138
|
+
(element: HTMLElement, config?: ConfigWithPlugins): Player;
|
|
139
|
+
}
|
|
90
140
|
|
|
91
141
|
declare interface FPEvent<T> extends CustomEvent<T> {
|
|
92
142
|
/**
|
|
@@ -107,35 +157,11 @@ declare interface Loader<PluginOwnConfig extends KeyValue = KeyValue> extends Pl
|
|
|
107
157
|
wants<S = KeyValue, T = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: PluginConfig<T>): boolean;
|
|
108
158
|
}
|
|
109
159
|
|
|
110
|
-
declare
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
160
|
+
declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
161
|
+
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
162
|
+
};
|
|
114
163
|
|
|
115
|
-
declare
|
|
116
|
-
type Src = {
|
|
117
|
-
streamName: string;
|
|
118
|
-
streamAccountId: string;
|
|
119
|
-
subscriberToken?: string;
|
|
120
|
-
type: "wowza/rts";
|
|
121
|
-
};
|
|
122
|
-
type ViewerCountEvent = {
|
|
123
|
-
type: string;
|
|
124
|
-
name: "viewercount";
|
|
125
|
-
data: ViewerCount;
|
|
126
|
-
};
|
|
127
|
-
type ActiveEvent = {
|
|
128
|
-
type: string;
|
|
129
|
-
name: "active";
|
|
130
|
-
data: MediaStreamSource;
|
|
131
|
-
};
|
|
132
|
-
type InactiveEvent = {
|
|
133
|
-
type: string;
|
|
134
|
-
name: "inactive";
|
|
135
|
-
data: MediaStreamSource;
|
|
136
|
-
};
|
|
137
|
-
type BroadcastEvent = ViewerCountEvent | ActiveEvent | InactiveEvent;
|
|
138
|
-
}
|
|
164
|
+
declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToConfigs<Arr>>;
|
|
139
165
|
|
|
140
166
|
declare interface Player extends HTMLVideoElement {
|
|
141
167
|
renderPlugin: (pluginContainer: HTMLElement) => void;
|
|
@@ -201,37 +227,15 @@ declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
|
201
227
|
|
|
202
228
|
declare type PluginConfig<T> = Config & T;
|
|
203
229
|
|
|
204
|
-
declare
|
|
205
|
-
|
|
206
|
-
rtsAdapter?: RTS.Adapter;
|
|
207
|
-
};
|
|
208
|
-
type Src = Millicast.Src | WowzaWebRTC.Src;
|
|
209
|
-
interface Adapter {
|
|
210
|
-
readonly log: Logger;
|
|
211
|
-
load(): void;
|
|
212
|
-
stop(): void;
|
|
213
|
-
}
|
|
214
|
-
type StatusMessage = {
|
|
215
|
-
status: Status;
|
|
216
|
-
message?: string;
|
|
217
|
-
data?: MediaStreamSource;
|
|
218
|
-
};
|
|
219
|
-
type ViewerCountEvent = {
|
|
220
|
-
viewerCount: number;
|
|
221
|
-
};
|
|
230
|
+
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
231
|
+
new (umd: FlowplayerUMD, player: Player): AnyPlugin<PluginOwnConfig>;
|
|
222
232
|
}
|
|
223
233
|
|
|
224
|
-
declare
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
engine?: RTS.Adapter;
|
|
229
|
-
constructor();
|
|
230
|
-
init(_config: Config, _root: PlayerRoot, player: RTS.Player): void;
|
|
231
|
-
onload(_config: Config, _root: PlayerRoot, video: RTS.Player, src: RTS.Src): void;
|
|
232
|
-
wants(_srcString: string, src: RTS.Src, _config: Config): boolean;
|
|
234
|
+
declare enum QualityOpts {
|
|
235
|
+
LOW = 1,
|
|
236
|
+
MEDIUM = 2,
|
|
237
|
+
HIGH = 4
|
|
233
238
|
}
|
|
234
|
-
export default RTSLoader;
|
|
235
239
|
|
|
236
240
|
declare type SourceObj = {
|
|
237
241
|
src?: SourceStr;
|
|
@@ -243,13 +247,6 @@ declare type SourceStr = string;
|
|
|
243
247
|
|
|
244
248
|
declare type SourceWith<T> = SourceObj & T;
|
|
245
249
|
|
|
246
|
-
declare const STATUS = "rts/status";
|
|
247
|
-
|
|
248
|
-
declare enum Status {
|
|
249
|
-
Idle = 0,
|
|
250
|
-
Receiving = 1
|
|
251
|
-
}
|
|
252
|
-
|
|
253
250
|
declare type UnsafeSource = SourceStr | SourceObj | Array<SourceStr | SourceObj>;
|
|
254
251
|
|
|
255
252
|
declare interface VideoTrack {
|
|
@@ -259,15 +256,4 @@ declare interface VideoTrack {
|
|
|
259
256
|
selected: boolean;
|
|
260
257
|
}
|
|
261
258
|
|
|
262
|
-
declare const VIEWER_COUNT = "rts/viewer-count";
|
|
263
|
-
|
|
264
|
-
declare namespace WowzaWebRTC {
|
|
265
|
-
type Src = {
|
|
266
|
-
sdpUrl: string;
|
|
267
|
-
applicationName: string;
|
|
268
|
-
streamName: string;
|
|
269
|
-
type: "wowza/webrtc";
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
259
|
export { }
|
package/plugins/rts.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* Copyright (c) 2018-2022 Koala Interactive, Inc.
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
|
-
function Df(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Mf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Df(Object(r),!0).forEach((function(t){_f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Df(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Nf(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function jf(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){Nf(o,n,i,s,a,"next",e)}function a(e){Nf(o,n,i,s,a,"throw",e)}s(void 0)}))}}function _f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bf(){}function Uf(){Uf.init.call(this)}function Vf(e){return void 0===e._maxListeners?Uf.defaultMaxListeners:e._maxListeners}function Ff(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Yf(e,n),o=0;o<n;++o)i[o].call(r)}function zf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].call(r,n)}function $f(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=Yf(e,o),a=0;a<o;++a)s[a].call(r,n,i)}function Gf(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=Yf(e,s),c=0;c<s;++c)a[c].call(r,n,i,o)}function Wf(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].apply(r,n)}function qf(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new Bf,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=Vf(e))&&i>0&&s.length>i){s.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Hf(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Xf(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Yf(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/rts",MillicastAdapter.Options={events:["active","inactive","viewercount"]},MillicastAdapter.WOWZA_DIRECTOR_ENDPOINT="https://realtime1.wowza.com",Bf.prototype=Object.create(null),Uf.EventEmitter=Uf,Uf.usingDomains=!1,Uf.prototype.domain=void 0,Uf.prototype._events=void 0,Uf.prototype._maxListeners=void 0,Uf.defaultMaxListeners=10,Uf.init=function(){this.domain=null,Uf.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Bf,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Uf.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Uf.prototype.getMaxListeners=function(){return Vf(this)},Uf.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:Ff(r,l,this);break;case 2:zf(r,l,this,arguments[1]);break;case 3:$f(r,l,this,arguments[1],arguments[2]);break;case 4:Gf(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];Wf(r,l,this,i)}return!0},Uf.prototype.addListener=function(e,t){return qf(this,e,t,!1)},Uf.prototype.on=Uf.prototype.addListener,Uf.prototype.prependListener=function(e,t){return qf(this,e,t,!0)},Uf.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Hf(this,e,t)),this},Uf.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Hf(this,e,t)),this},Uf.prototype.removeListener=function(e,t){var r,n,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Bf:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Bf,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},Uf.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Bf,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Bf:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Bf,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Uf.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Uf.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Xf.call(e,t)},Uf.prototype.listenerCount=Xf,Uf.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Jf=window.RTCPeerConnection,Kf=window.RTCIceCandidate,Zf=window.RTCSessionDescription;class b extends Uf{constructor(e){super(),_f(this,"pc",void 0),this.pc=new Jf({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Zf(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Zf(e))}createAnswer(){var e=this;return jf((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return jf((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new Kf(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,_f(this,"ws",null),_f(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return jf((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(Mf(Mf({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Qf="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",ep=["vp9","vp8","h264","red","ulpfec","rtx"],tp=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,_f(this,"audioIndex",-1),_f(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,i=r>>8&255,o=255&r;return n>66?(n=66,i=224,o=31):0===i&&(i=224),"profile-level-id=".concat((n<<16|i<<8|o).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,i=null,o=()=>"m=audio"===i?n:"m=video"===i?r:null,s=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var s="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==s&&"chrome"===Qf){var[a,c,u]=e.split(" ");return"".concat(a," ").concat(c," ").concat(u," ").concat(s)}i=t;break;case"a=rtpmap":var l=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!l||"chrome"!==Qf)break;var d=l[2].toLowerCase();r.bitRate&&ep.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&tp.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var f=o();if(null!=f&&f.bitRate&&["firefox","safari"].includes(Qf)){var p=1e3*f.bitRate;e+="\r\nb=TIAS:".concat(.95*p-16e3),e+="\r\nb=AS:".concat(p),e+="\r\nb=CT:".concat(p)}break;case"a=mid":var h=o();h&&"chrome"===Qf&&(h.bitRate&&(e+="\r\nb=CT:".concat(h.bitRate),e+="\r\nb=AS:".concat(h.bitRate),"frameRate"in h&&h.frameRate&&(e+="\r\na=framerate:".concat(h.frameRate.toFixed(2)))),i=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:s}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,i]=r[1].split(" ");if(!i.startsWith("http")&&!i.startsWith("ur")){var o=parseInt(n,10),s=t.get(o)||[];return s.push(e),t.set(o,s),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[i,o]=n;return"audio"===t?this.audioIndex=i:this.videoIndex=i,"VP8"!==e&&"VP9"!==e?o:o.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,i=e.length;n<i;++n){var o=e[n];if(o.startsWith("m=audio"))r="audio";else if(o.startsWith("m=video"))r="video";else if("a=rtcp-mux"===o&&"audio"===r){var s=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...s);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),i=!1;if(!r&&!n)return e;var o=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!i&&"a=rtcp-rsize"===e)return i=!0,[e].concat(o).join("\r\n")}else if("a=rtcp-mux"===e){if(i)return[e].concat(o).join("\r\n");i=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends Uf{constructor(e,t){super(),this.video=e,_f(this,"sdpUrl",""),_f(this,"applicationName",""),_f(this,"streamName",""),_f(this,"userData",null),_f(this,"sdpHandler",void 0),_f(this,"secureToken",void 0),_f(this,"constraints",{audio:!0,video:!0}),_f(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),_f(this,"audioConfigs",{codec:"opus",bitRate:64}),_f(this,"iceServers",[]),_f(this,"mediaStream",null),_f(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return jf((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),i=t.createPeerConnection();i.on("addstream",t.attachStream.bind(t)),yield i.setRemoteDescription(n);var o=yield i.createAnswer(),s=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(o,e=>s.transformPlay(e),"play"):s.transformPlay(o);yield i.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),i=t.createPeerConnection();i.attachMediaStream(n);var o=new S(t.videoConfigs,t.audioConfigs),s=yield i.createOffer(),a=t.sdpHandler?t.sdpHandler(s,e=>o.transformPublish(e),"publish"):o.transformPublish(s);yield i.setLocalDescription(a);var{sdp:c,iceCandidates:u}=yield r.sendOffer(a);yield i.setRemoteDescription(c),u.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return jf((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n}static wants(e){return e.type==WowzaWebRTCAdapter.Type}async load(){this.log("loading",this.src.streamName),this.player.original_src=this.src.sdpUrl,this.engine=new x(this.player,this.src),await this.playRemote()}async playRemote(){var e;try{await(null===(e=this.engine)||void 0===e?void 0:e.playRemote())}catch(e){this.player.emit("error",null!=e?e:{fatal:!1}),setTimeout(()=>{0==this.player.reaper||this.player.currentSrc||(this.player.emit("recover"),this.playRemote())},3e3)}}async stop(){var e;await(null===(e=this.engine)||void 0===e?void 0:e.stop())}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";class RTSLoader{constructor(){this.log=t("rts")}init(e,t,r){r.on("reap",()=>{var e;return null===(e=this.engine)||void 0===e?void 0:e.stop()})}onload(e,t,r,n){var i;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(i=this.engine)||void 0===i||i.load()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}return RTSLoader.events=Lf,RTSLoader.state=Of,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 r=e.flowplayer;"function"==typeof r?r(t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t))}(window,RTSLoader),RTSLoader}));
|
|
7
|
+
function Df(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Mf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Df(Object(r),!0).forEach((function(t){_f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Df(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Nf(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function jf(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){Nf(o,n,i,s,a,"next",e)}function a(e){Nf(o,n,i,s,a,"throw",e)}s(void 0)}))}}function _f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bf(){}function Uf(){Uf.init.call(this)}function Vf(e){return void 0===e._maxListeners?Uf.defaultMaxListeners:e._maxListeners}function Ff(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Yf(e,n),o=0;o<n;++o)i[o].call(r)}function zf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].call(r,n)}function $f(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=Yf(e,o),a=0;a<o;++a)s[a].call(r,n,i)}function Gf(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=Yf(e,s),c=0;c<s;++c)a[c].call(r,n,i,o)}function Wf(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=Yf(e,i),s=0;s<i;++s)o[s].apply(r,n)}function qf(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new Bf,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=Vf(e))&&i>0&&s.length>i){s.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Hf(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Xf(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Yf(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/rts",MillicastAdapter.Options={events:["active","inactive","viewercount"]},MillicastAdapter.WOWZA_DIRECTOR_ENDPOINT="https://realtime1.wowza.com",Bf.prototype=Object.create(null),Uf.EventEmitter=Uf,Uf.usingDomains=!1,Uf.prototype.domain=void 0,Uf.prototype._events=void 0,Uf.prototype._maxListeners=void 0,Uf.defaultMaxListeners=10,Uf.init=function(){this.domain=null,Uf.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Bf,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Uf.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Uf.prototype.getMaxListeners=function(){return Vf(this)},Uf.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:Ff(r,l,this);break;case 2:zf(r,l,this,arguments[1]);break;case 3:$f(r,l,this,arguments[1],arguments[2]);break;case 4:Gf(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];Wf(r,l,this,i)}return!0},Uf.prototype.addListener=function(e,t){return qf(this,e,t,!1)},Uf.prototype.on=Uf.prototype.addListener,Uf.prototype.prependListener=function(e,t){return qf(this,e,t,!0)},Uf.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Hf(this,e,t)),this},Uf.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Hf(this,e,t)),this},Uf.prototype.removeListener=function(e,t){var r,n,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Bf:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Bf,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},Uf.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Bf,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Bf:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Bf,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Uf.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Uf.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Xf.call(e,t)},Uf.prototype.listenerCount=Xf,Uf.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Jf=window.RTCPeerConnection,Kf=window.RTCIceCandidate,Zf=window.RTCSessionDescription;class b extends Uf{constructor(e){super(),_f(this,"pc",void 0),this.pc=new Jf({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Zf(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Zf(e))}createAnswer(){var e=this;return jf((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return jf((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new Kf(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,_f(this,"ws",null),_f(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return jf((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(Mf(Mf({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Qf="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",ep=["vp9","vp8","h264","red","ulpfec","rtx"],tp=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,_f(this,"audioIndex",-1),_f(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,i=r>>8&255,o=255&r;return n>66?(n=66,i=224,o=31):0===i&&(i=224),"profile-level-id=".concat((n<<16|i<<8|o).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,i=null,o=()=>"m=audio"===i?n:"m=video"===i?r:null,s=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var s="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==s&&"chrome"===Qf){var[a,c,u]=e.split(" ");return"".concat(a," ").concat(c," ").concat(u," ").concat(s)}i=t;break;case"a=rtpmap":var l=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!l||"chrome"!==Qf)break;var d=l[2].toLowerCase();r.bitRate&&ep.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&tp.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var f=o();if(null!=f&&f.bitRate&&["firefox","safari"].includes(Qf)){var p=1e3*f.bitRate;e+="\r\nb=TIAS:".concat(.95*p-16e3),e+="\r\nb=AS:".concat(p),e+="\r\nb=CT:".concat(p)}break;case"a=mid":var h=o();h&&"chrome"===Qf&&(h.bitRate&&(e+="\r\nb=CT:".concat(h.bitRate),e+="\r\nb=AS:".concat(h.bitRate),"frameRate"in h&&h.frameRate&&(e+="\r\na=framerate:".concat(h.frameRate.toFixed(2)))),i=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:s}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,i]=r[1].split(" ");if(!i.startsWith("http")&&!i.startsWith("ur")){var o=parseInt(n,10),s=t.get(o)||[];return s.push(e),t.set(o,s),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[i,o]=n;return"audio"===t?this.audioIndex=i:this.videoIndex=i,"VP8"!==e&&"VP9"!==e?o:o.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,i=e.length;n<i;++n){var o=e[n];if(o.startsWith("m=audio"))r="audio";else if(o.startsWith("m=video"))r="video";else if("a=rtcp-mux"===o&&"audio"===r){var s=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...s);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),i=!1;if(!r&&!n)return e;var o=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!i&&"a=rtcp-rsize"===e)return i=!0,[e].concat(o).join("\r\n")}else if("a=rtcp-mux"===e){if(i)return[e].concat(o).join("\r\n");i=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends Uf{constructor(e,t){super(),this.video=e,_f(this,"sdpUrl",""),_f(this,"applicationName",""),_f(this,"streamName",""),_f(this,"userData",null),_f(this,"sdpHandler",void 0),_f(this,"secureToken",void 0),_f(this,"constraints",{audio:!0,video:!0}),_f(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),_f(this,"audioConfigs",{codec:"opus",bitRate:64}),_f(this,"iceServers",[]),_f(this,"mediaStream",null),_f(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return jf((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),i=t.createPeerConnection();i.on("addstream",t.attachStream.bind(t)),yield i.setRemoteDescription(n);var o=yield i.createAnswer(),s=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(o,e=>s.transformPlay(e),"play"):s.transformPlay(o);yield i.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return jf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),i=t.createPeerConnection();i.attachMediaStream(n);var o=new S(t.videoConfigs,t.audioConfigs),s=yield i.createOffer(),a=t.sdpHandler?t.sdpHandler(s,e=>o.transformPublish(e),"publish"):o.transformPublish(s);yield i.setLocalDescription(a);var{sdp:c,iceCandidates:u}=yield r.sendOffer(a);yield i.setRemoteDescription(c),u.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return jf((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n}static wants(e){return e.type==WowzaWebRTCAdapter.Type}async load(){this.log("loading",this.src.streamName),this.player.original_src=this.src.sdpUrl,this.engine=new x(this.player,this.src),await this.playRemote()}async playRemote(){var e;try{await(null===(e=this.engine)||void 0===e?void 0:e.playRemote())}catch(e){this.player.emit("error",null!=e?e:{fatal:!1}),setTimeout(()=>{0==this.player.reaper||this.player.currentSrc||(this.player.emit("recover"),this.playRemote())},3e3)}}async stop(){var e;await(null===(e=this.engine)||void 0===e?void 0:e.stop())}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";class RTSLoader{constructor(){this.log=t("rts")}init(e,t,r){r.on("reap",()=>{var e;return null===(e=this.engine)||void 0===e?void 0:e.stop()})}onload(e,t,r,n){var i;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(i=this.engine)||void 0===i||i.load()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}return RTSLoader.events=Lf,RTSLoader.state=Of,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 r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}(window,RTSLoader)}));
|
package/plugins/share.d.ts
CHANGED
|
@@ -75,6 +75,9 @@ declare interface Config {
|
|
|
75
75
|
|
|
76
76
|
declare type CustomConfig<T> = Config & T;
|
|
77
77
|
|
|
78
|
+
declare const _default: PluginCtor<KeyValue>;
|
|
79
|
+
export default _default;
|
|
80
|
+
|
|
78
81
|
declare type DeviceId = string;
|
|
79
82
|
|
|
80
83
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
|
@@ -158,13 +161,6 @@ declare type MapToConfigs<Arr extends PluginCtor[]> = {
|
|
|
158
161
|
[PluginType in keyof Arr]: Arr[PluginType] extends PluginCtor<infer ConfigType> ? ConfigType : never;
|
|
159
162
|
};
|
|
160
163
|
|
|
161
|
-
declare type MenuOption = {
|
|
162
|
-
text: string;
|
|
163
|
-
onclick: () => any;
|
|
164
|
-
icon?: HTMLElement;
|
|
165
|
-
selected?: boolean;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
164
|
declare type MergeConfigs<Arr extends PluginCtor[]> = ArrayToIntersection<MapToConfigs<Arr>>;
|
|
169
165
|
|
|
170
166
|
declare interface Player extends HTMLVideoElement {
|
|
@@ -219,26 +215,8 @@ declare type PlayerRoot = HTMLElement & {
|
|
|
219
215
|
prevWidth?: number;
|
|
220
216
|
};
|
|
221
217
|
|
|
222
|
-
declare namespace Players {
|
|
223
|
-
export {
|
|
224
|
-
VideoTrack,
|
|
225
|
-
PlayerState,
|
|
226
|
-
FPEvent,
|
|
227
|
-
DeviceId,
|
|
228
|
-
JSONPlayer,
|
|
229
|
-
PlayerRoot,
|
|
230
|
-
Player
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
218
|
declare type PlayerState = string;
|
|
235
219
|
|
|
236
|
-
declare type PlayerWith<T> = Players.Player & T;
|
|
237
|
-
|
|
238
|
-
declare type PlayerWithMessage = PlayerWith<{
|
|
239
|
-
message?: string;
|
|
240
|
-
}>;
|
|
241
|
-
|
|
242
220
|
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue> {
|
|
243
221
|
/**
|
|
244
222
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
@@ -259,18 +237,6 @@ declare enum QualityOpts {
|
|
|
259
237
|
HIGH = 4
|
|
260
238
|
}
|
|
261
239
|
|
|
262
|
-
declare class Share implements Plugin_2 {
|
|
263
|
-
private umd;
|
|
264
|
-
static events: {
|
|
265
|
-
OPTIONS: string;
|
|
266
|
-
};
|
|
267
|
-
private share_options;
|
|
268
|
-
constructor(umd: FlowplayerUMD);
|
|
269
|
-
init(config: Config, container: PlayerRoot, player: PlayerWithMessage): void;
|
|
270
|
-
add_options(player: Player, ...options: MenuOption[]): void;
|
|
271
|
-
}
|
|
272
|
-
export default Share;
|
|
273
|
-
|
|
274
240
|
declare type SourceObj = {
|
|
275
241
|
src?: SourceStr;
|
|
276
242
|
type?: string;
|
package/plugins/share.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.share=t())}(this,(function(){"use strict";const e={name:"fp-facebook"},t={name:"fp-link"},n={name:"fp-share"},s={name:"fp-embed"},i={name:"fp-twitter"};function o(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function r(){try{return(document.querySelector("meta[name='description']")||{content:""}).content}catch(e){return""}}function l(e){if("string"==typeof e.link)return e.link;const t=document.querySelector("link[rel=canonical]");return t?t.href:window.location.toString()}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),c=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)},u="fp-on",d="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=h(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{if(t.defaultPrevented)return;t.preventDefault();const n=this.menuContainer.open;n||(m(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||h()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(u,n===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(u)})}toggle_visibility(e){this.classList.toggle(d,e),this.menu.style.setProperty("display",e?"none":"flex")}}function m(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function h(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function p(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(m(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const y="flowplayer-share-menu";class Share{constructor(o){this.umd=o,this.share_options=[],c(o,y,FlowplayerMenu),c(this.umd,"flowplayer-facebook-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),c(this.umd,"flowplayer-twitter-icon",class extends FlowplayerIcon{constructor(e){super(e,i)}}),c(this.umd,"flowplayer-link-icon",class extends FlowplayerIcon{constructor(e){super(e,t)}}),c(this.umd,"flowplayer-embed-icon",class extends FlowplayerIcon{constructor(e){super(e,s)}}),c(this.umd,"flowplayer-share-icon",class extends FlowplayerIcon{constructor(e){super(e,n)}})}init(e,t,n){const s=a(n,y);s instanceof FlowplayerMenu&&s.setMenuAttrs({menuTitle:n.i18n("share.menu_title"),class:"fp-share-menu fp-togglable",summaryIcon:"flowplayer-share-icon",icons:!0,options_event:Share.events.OPTIONS});const i={prev_config:0,webshare_listener:0};n.on("mount",(function(){var e;null===(e=f(n,"flowplayer-header-left-zone"))||void 0===e||e.append(s),s instanceof FlowplayerMenu&&s.menuContainer.addEventListener("toggle",(function(){t.classList.toggle("is-share-menu",this.open);const e=f(n,"flowplayer-control");this.open&&(t.classList.contains("is-small")?n.pause():e&&function(e,t){if(!t)return;e.menu.style.maxHeight=t.getBoundingClientRect().top+parseFloat(window.getComputedStyle(t).getPropertyValue("padding"))-e.menuContainer.getBoundingClientRect().bottom+"px"}(s,e))}))})),n.on("config",t=>{const c=o(t,"data.share",{});if(!1===c)return s instanceof FlowplayerMenu&&void s.classList.remove("webshare-enabled");if(i.prev_config===c)return;if(i.prev_config=c,s instanceof FlowplayerMenu&&function(){try{return"https:"===window.location.protocol&&"function"==typeof navigator.share}catch(e){return!1}}()&&o(c,"web_share",!0))return function(e){e.classList.add("webshare-enabled")}(s),i.webshare_listener||function(e,t,n){n.webshare_listener=!0,t.addEventListener("click",(function(){if(!t.classList.contains("webshare-enabled"))return;t.menuContainer.open=!1;navigator.share({title:o(e,"share.title",document.title),text:o(e,"share.text",r()),url:l(o(e,"share",{}))}).catch((function(){}))}))}(e,s,i);this.share_options=[];const u="string"==typeof c.link?c.link:window.location.toString();if(c.iframe){const e="string"==typeof c.iframe?c.iframe:u;this.share_options.push(w(n,s,"share.embed",g.bind(null,e,n),a(n,"flowplayer-embed-icon")))}c.link&&this.share_options.push(w(n,s,"share.link",v.bind(null,u),a(n,"flowplayer-link-icon"))),c.facebook&&this.share_options.push(w(n,s,"Facebook",_.bind(null,u),a(n,"flowplayer-facebook-icon"))),c.twitter&&this.share_options.push(w(n,s,"Twitter",x.bind(null,u),a(n,"flowplayer-twitter-icon"))),p(s,Share.events.OPTIONS,this.share_options)})}add_options(e,...t){const n=e.root.querySelector(y);n&&t.forEach(t=>{const s=w(e,n,t.text,t.onclick,t.icon);n.menuOption(s,n.options.length)})}}function w(e,t,n,s,i){return{text:b(e,n),icon:i,onclick:E.bind(null,e,t,s)}}function b(e,t){return 0===t.indexOf("share.")?e.i18n(t):t}function E(e,t,n){t instanceof FlowplayerMenu&&t.unselect_item();const s=n();s.success&&s.message&&e.message&&e.emit(e.message.events.SHOW_MESSAGE,{message:s.message})}function g(e,t){const n=t.videoHeight/t.videoWidth;return v('<div style="position:relative;width:100%;display:inline-block;"><iframe src="__IFRAME_SRC__" allowfullscreen style="border:none;position:absolute;top:0;left:0;width:100%;height:100%;"></iframe><div style="padding-top: __RATIO__%;"></div></div>'.replace("__IFRAME_SRC__",encodeURI(e)).replace("__RATIO__",""+100*n))}function v(e){const t=document.createElement("textarea");t.setAttribute("style","position:absolute;opacity:0"),t.value=e;const n=document.body;n.append(t),t.select();const s=document.execCommand("copy");return n.removeChild(t),{success:s,message:s?"<trans share.clipboard_success trans>":"<trans share.clipboard_failure trans>"}}function _(e){return A("https://www.facebook.com/sharer.php?u="+encodeURIComponent(e)),{success:!0}}function x(e){return A("https://twitter.com/intent/tweet?url="+encodeURIComponent(e)),{success:!0}}function A(e){let t;const n=screen.height,s=screen.width,i=Math.round(s/2-275);t=0,n>420&&(t=Math.round(n/2-210)),window.open(e,"sharer","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,left="+i+",top="+t)}return Share.events={OPTIONS:"share:options"},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,Share),Share}));
|
|
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.share=t())}(this,(function(){"use strict";const e={name:"fp-facebook"},t={name:"fp-link"},n={name:"fp-share"},s={name:"fp-embed"},i={name:"fp-twitter"};function o(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function r(){try{return(document.querySelector("meta[name='description']")||{content:""}).content}catch(e){return""}}function l(e){if("string"==typeof e.link)return e.link;const t=document.querySelector("link[rel=canonical]");return t?t.href:window.location.toString()}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),c=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)},u="fp-on",d="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=h(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{if(t.defaultPrevented)return;t.preventDefault();const n=this.menuContainer.open;n||(m(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||h()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(u,n===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(u)})}toggle_visibility(e){this.classList.toggle(d,e),this.menu.style.setProperty("display",e?"none":"flex")}}function m(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function h(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function p(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(m(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const y="flowplayer-share-menu";class Share{constructor(o){this.umd=o,this.share_options=[],c(o,y,FlowplayerMenu),c(this.umd,"flowplayer-facebook-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),c(this.umd,"flowplayer-twitter-icon",class extends FlowplayerIcon{constructor(e){super(e,i)}}),c(this.umd,"flowplayer-link-icon",class extends FlowplayerIcon{constructor(e){super(e,t)}}),c(this.umd,"flowplayer-embed-icon",class extends FlowplayerIcon{constructor(e){super(e,s)}}),c(this.umd,"flowplayer-share-icon",class extends FlowplayerIcon{constructor(e){super(e,n)}})}init(e,t,n){const s=a(n,y);s instanceof FlowplayerMenu&&s.setMenuAttrs({menuTitle:n.i18n("share.menu_title"),class:"fp-share-menu fp-togglable",summaryIcon:"flowplayer-share-icon",icons:!0,options_event:Share.events.OPTIONS});const i={prev_config:0,webshare_listener:0};n.on("mount",(function(){var e;null===(e=f(n,"flowplayer-header-left-zone"))||void 0===e||e.append(s),s instanceof FlowplayerMenu&&s.menuContainer.addEventListener("toggle",(function(){t.classList.toggle("is-share-menu",this.open);const e=f(n,"flowplayer-control");this.open&&(t.classList.contains("is-small")?n.pause():e&&function(e,t){if(!t)return;e.menu.style.maxHeight=t.getBoundingClientRect().top+parseFloat(window.getComputedStyle(t).getPropertyValue("padding"))-e.menuContainer.getBoundingClientRect().bottom+"px"}(s,e))}))})),n.on("config",t=>{const c=o(t,"data.share",{});if(!1===c)return s instanceof FlowplayerMenu&&void s.classList.remove("webshare-enabled");if(i.prev_config===c)return;if(i.prev_config=c,s instanceof FlowplayerMenu&&function(){try{return"https:"===window.location.protocol&&"function"==typeof navigator.share}catch(e){return!1}}()&&o(c,"web_share",!0))return function(e){e.classList.add("webshare-enabled")}(s),i.webshare_listener||function(e,t,n){n.webshare_listener=!0,t.addEventListener("click",(function(){if(!t.classList.contains("webshare-enabled"))return;t.menuContainer.open=!1;navigator.share({title:o(e,"share.title",document.title),text:o(e,"share.text",r()),url:l(o(e,"share",{}))}).catch((function(){}))}))}(e,s,i);this.share_options=[];const u="string"==typeof c.link?c.link:window.location.toString();if(c.iframe){const e="string"==typeof c.iframe?c.iframe:u;this.share_options.push(w(n,s,"share.embed",g.bind(null,e,n),a(n,"flowplayer-embed-icon")))}c.link&&this.share_options.push(w(n,s,"share.link",v.bind(null,u),a(n,"flowplayer-link-icon"))),c.facebook&&this.share_options.push(w(n,s,"Facebook",_.bind(null,u),a(n,"flowplayer-facebook-icon"))),c.twitter&&this.share_options.push(w(n,s,"Twitter",x.bind(null,u),a(n,"flowplayer-twitter-icon"))),p(s,Share.events.OPTIONS,this.share_options)})}add_options(e,...t){const n=e.root.querySelector(y);n&&t.forEach(t=>{const s=w(e,n,t.text,t.onclick,t.icon);n.menuOption(s,n.options.length)})}}function w(e,t,n,s,i){return{text:b(e,n),icon:i,onclick:E.bind(null,e,t,s)}}function b(e,t){return 0===t.indexOf("share.")?e.i18n(t):t}function E(e,t,n){t instanceof FlowplayerMenu&&t.unselect_item();const s=n();s.success&&s.message&&e.message&&e.emit(e.message.events.SHOW_MESSAGE,{message:s.message})}function g(e,t){const n=t.videoHeight/t.videoWidth;return v('<div style="position:relative;width:100%;display:inline-block;"><iframe src="__IFRAME_SRC__" allowfullscreen style="border:none;position:absolute;top:0;left:0;width:100%;height:100%;"></iframe><div style="padding-top: __RATIO__%;"></div></div>'.replace("__IFRAME_SRC__",encodeURI(e)).replace("__RATIO__",""+100*n))}function v(e){const t=document.createElement("textarea");t.setAttribute("style","position:absolute;opacity:0"),t.value=e;const n=document.body;n.append(t),t.select();const s=document.execCommand("copy");return n.removeChild(t),{success:s,message:s?"<trans share.clipboard_success trans>":"<trans share.clipboard_failure trans>"}}function _(e){return A("https://www.facebook.com/sharer.php?u="+encodeURIComponent(e)),{success:!0}}function x(e){return A("https://twitter.com/intent/tweet?url="+encodeURIComponent(e)),{success:!0}}function A(e){let t;const n=screen.height,s=screen.width,i=Math.round(s/2-275);t=0,n>420&&(t=Math.round(n/2-210)),window.open(e,"sharer","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,left="+i+",top="+t)}return Share.events={OPTIONS:"share:options"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Share)}));
|
package/plugins/speed.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ declare interface Config {
|
|
|
75
75
|
|
|
76
76
|
declare type CustomConfig<T> = Config & T;
|
|
77
77
|
|
|
78
|
-
declare const _default:
|
|
78
|
+
declare const _default: PluginCtor<KeyValue>;
|
|
79
79
|
export default _default;
|
|
80
80
|
|
|
81
81
|
declare type DeviceId = string;
|
|
@@ -247,15 +247,6 @@ declare type SourceStr = string;
|
|
|
247
247
|
|
|
248
248
|
declare type SourceWith<T> = SourceObj & T;
|
|
249
249
|
|
|
250
|
-
declare class Speed implements Plugin_2 {
|
|
251
|
-
static DEFAULT_SPEED_OPTIONS: number[];
|
|
252
|
-
static events: {
|
|
253
|
-
OPTIONS: string;
|
|
254
|
-
};
|
|
255
|
-
constructor(umd: FlowplayerUMD);
|
|
256
|
-
init(config: Config, container: PlayerRoot, player: Player): void;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
250
|
declare type UnsafeSource = SourceStr | SourceObj | Array<SourceStr | SourceObj>;
|
|
260
251
|
|
|
261
252
|
declare interface VideoTrack {
|