ezuikit-flv 1.0.3-beta.2 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/index.d.ts CHANGED
@@ -2,12 +2,16 @@ export default EzuikitFlv;
2
2
  /**
3
3
  * @classdesc EzuikitFlv.js 播放flv直播流, 支持播放h264/h265的直播视频流
4
4
  * @example
5
+ *
6
+ * import "ezuikit-flv/style.css"
7
+ * import EzuikitFlv from 'ezuikit-flv'
8
+ *
5
9
  * const flv = new EzuikitFlv({
6
10
  * id: "EleId",
7
11
  * url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv"
8
12
  * })
9
13
  */
10
- declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
14
+ declare class EzuikitFlv extends Theme {
11
15
  /**
12
16
  * @description EzuikitFlv error events
13
17
  * @static
@@ -31,6 +35,109 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
31
35
  wasmDecodeError: string;
32
36
  webglAlignmentError: string;
33
37
  };
38
+ static EVENTS: {
39
+ fullscreenChange: string;
40
+ orientationChange: string;
41
+ decoderWorkerInit: string;
42
+ play: string;
43
+ playing: string;
44
+ pause: string;
45
+ mute: string;
46
+ load: string;
47
+ loading: string;
48
+ loaded: string;
49
+ videoInfo: string;
50
+ timeUpdate: string;
51
+ timeUpdateOSD: string;
52
+ audioInfo: string;
53
+ log: string;
54
+ error: string;
55
+ kBps: string;
56
+ timeout: string;
57
+ heartTimeout: string;
58
+ heartRetryTimes: string;
59
+ delayTimeout: string;
60
+ loadingTimeout: string;
61
+ loadingRetryTimes: string;
62
+ stats: string;
63
+ performance: string;
64
+ buffer: string;
65
+ videoFrame: string;
66
+ start: string;
67
+ metadata: string;
68
+ resize: string;
69
+ streamEnd: string;
70
+ streamSuccess: string;
71
+ streamMessage: string;
72
+ streamError: string;
73
+ volumechange: string;
74
+ audioCodecUnsupported: string;
75
+ unrecoverableEarlyEof: string;
76
+ destroy: string;
77
+ mseSourceOpen: string;
78
+ mseSourceClose: string;
79
+ mseSourceBufferError: string;
80
+ mseSourceBufferBusy: string;
81
+ mseSourceBufferFull: string;
82
+ videoWaiting: string;
83
+ videoTimeUpdate: string;
84
+ videoSyncAudio: string;
85
+ playToRenderTimes: string;
86
+ localVideoRecords: string;
87
+ getDefinitionListResult: string;
88
+ definitionChange: string;
89
+ definitionListChange: string;
90
+ playbackRateListChange: string;
91
+ playbackRateChange: string;
92
+ decoderLoaded: string;
93
+ end: string;
94
+ } & {
95
+ loading: string;
96
+ play: string;
97
+ capturePicture: string;
98
+ volumechange: string;
99
+ audioInfo: string;
100
+ videoInfo: string;
101
+ fullscreen: string;
102
+ exitFullscreen: string;
103
+ fullscreenChange: string;
104
+ resize: string;
105
+ orientationChange: string;
106
+ audioCodecUnsupported: string;
107
+ changeTheme: string;
108
+ changeRecType: string;
109
+ changeDefinition: string;
110
+ changeSpeed: string;
111
+ control: {
112
+ play: string; /**
113
+ * @description 初始化播放
114
+ * @private
115
+ * @param {string | HTMLElement} $container
116
+ * @param {FlvOptions} options
117
+ * @return {void}
118
+ */
119
+ capturePicture: string;
120
+ volumechange: string;
121
+ volumePanelOpenChange: string;
122
+ controlsBarOpenChange: string;
123
+ headerMoreShow: string;
124
+ footerMoreShow: string;
125
+ beforeMountControls: string;
126
+ mountedControls: string;
127
+ beforeUnmountControls: string;
128
+ unmountedControls: string;
129
+ changeRecType: string;
130
+ changeDefinition: string;
131
+ definitionPanelOpenChange: string;
132
+ changeSpeed: string;
133
+ speedPanelOpenChange: string;
134
+ };
135
+ theme: {
136
+ beforeDestroy: string;
137
+ destroyed: string;
138
+ };
139
+ message: string;
140
+ };
34
141
  static QUALITY_ENUM: {
35
142
  0: string;
36
143
  1: string;
@@ -52,7 +159,11 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
52
159
  * @returns {FlvOptions}
53
160
  */
54
161
  private static _setOptions;
55
- /** 版本号 EzuikitFlv.version */
162
+ /**
163
+ * 版本号 EzuikitFlv.version
164
+ * @example
165
+ * EzuikitFlv.version
166
+ */
56
167
  static version: string;
57
168
  /**
58
169
  * @description 静态方法 判断是否支持播放地址
@@ -74,14 +185,15 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
74
185
  * @param {FlvOptions} options
75
186
  */
76
187
  constructor(options: FlvOptions);
77
- event: EventEmitter<string | symbol, any>;
78
188
  urlInfo: {};
79
189
  /** @type {Services} */
80
190
  services: Services;
81
191
  /** @private */
82
192
  private _loadingTimeoutDelayTimer;
193
+ _heartTimeoutDelayTimer: any;
83
194
  _opt: any;
84
195
  $container: any;
196
+ _heartTimeoutDelayTimes: number;
85
197
  _loadingTimeoutReplayTimes: number;
86
198
  events: Events;
87
199
  _videoInfo: {};
@@ -94,6 +206,7 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
94
206
  private _playbackRate;
95
207
  playbackRateList: number[];
96
208
  playbackRecords: any[];
209
+ _onvisibilitychange(): void;
97
210
  /**
98
211
  * https 接口调用 仅针对萤石设备
99
212
  * @since @1.0.3
@@ -152,16 +265,6 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
152
265
  * @returns {boolean}
153
266
  */
154
267
  private _isEzvizPlayback;
155
- /**
156
- * 当前是否在播放中
157
- */
158
- get playing(): any;
159
- /**
160
- * @description 销毁
161
- * @example
162
- * flv.destroy()
163
- */
164
- destroy(): void;
165
268
  player: Player;
166
269
  /**
167
270
  * @private
@@ -191,8 +294,9 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
191
294
  * @description 是否开启控制台调试打印
192
295
  * @param {boolean} value true: 开启, false: 关闭
193
296
  * @returns {void}
297
+ * @deprecated 推荐 player.setLogger({level: "WARN"}), 后面版本会移除
194
298
  * @example
195
- * flv.setDebug(false)
299
+ * player.setDebug(false)
196
300
  */
197
301
  setDebug(value: boolean): void;
198
302
  /**
@@ -202,51 +306,45 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
202
306
  */
203
307
  setLogger(opt?: {}): void;
204
308
  /**
205
- * @description 关闭声音
309
+ * @description 关闭声音(非静音)
206
310
  * @returns {void}
311
+ * @deprecated 推荐 player.volume = 0, 后面版本会移除
207
312
  * @example
208
- * flv.closeSound()
313
+ * player.closeSound()
209
314
  */
210
315
  closeSound(): void;
211
316
  /**
212
- * @description 开启声音 默认音量 0.5
317
+ * @description 开启声音 默认音量 0.8,
213
318
  * @returns {void}
319
+ * @deprecated 推荐 player.volume = 0.8, 后面版本会移除
214
320
  * @example
215
- * flv.openSound() //
321
+ * player.openSound() //
216
322
  */
217
323
  openSound(): void;
218
324
  /**
219
325
  * @description 设置音量
220
326
  * @param {number} value 音量 0~1
221
327
  * @returns {void}
328
+ * @deprecated 后面版本会移除, 推荐 player.volume = 0.8,
222
329
  * @example
223
- * flv.setVolume(0.5)
330
+ * player.setVolume(0.8)
224
331
  */
225
332
  setVolume(value: number): void;
226
- set volume(value: any);
227
- get volume(): any;
228
333
  /**
229
334
  * @description 获取音量, 音量 0~1
230
335
  * @returns {number}
336
+ * @deprecated 后面版本会移除, 推荐 player.volume
231
337
  * @example
232
- * flv.getVolume()
338
+ * player.getVolume()
233
339
  */
234
340
  getVolume(): number;
235
341
  /**
236
342
  * @description 音频恢复
237
343
  * @returns {void}
238
344
  * @example
239
- * flv.audioResume()
345
+ * player.audioResume()
240
346
  */
241
347
  audioResume(): void;
242
- /**
243
- * @description 设置超时时长, 单位秒 在连接成功之前和播放中途,如果超过设定时长无数据返回,则回调timeout事件
244
- * @private
245
- * @param {number} time 设置超时时长, 单位秒
246
- * @returns {void}
247
- * @example
248
- * flv.setTimeout(3)
249
- */
250
348
  /**
251
349
  * @description 设置渲染的模式 (video 不支持)
252
350
  * @private
@@ -296,6 +394,10 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
296
394
  * @private
297
395
  */
298
396
  private _onDelayTimeout;
397
+ /**
398
+ * @private
399
+ */
400
+ private _onHeartTimeout;
299
401
  /**
300
402
  * @private
301
403
  */
@@ -309,14 +411,10 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
309
411
  */
310
412
  private _onStreamError;
311
413
  /**
312
- * @description 重新调整视图大小
313
- * @param {number=} width 宽
314
- * @param {number=} height 高
315
- * @example
316
- *
317
- * flv.resize()
414
+ * 获取萤石直播间播放失败的原因
415
+ * @private
318
416
  */
319
- resize(width?: number | undefined, height?: number | undefined): void;
417
+ private _getDeviceStreamErrorInfo;
320
418
  /**
321
419
  * @description 设置最大缓冲时长,单位秒,播放器会自动消除延迟。软解
322
420
  * @private
@@ -329,6 +427,7 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
329
427
  * @description 设置旋转角度,支持,0(默认), 90, 180, 270 四个值。
330
428
  * @param {number} deg 旋转角度取值 EzuikitFlv.ROTATE
331
429
  * @returns {Promise}
430
+ * @deprecated 不在使用
332
431
  * @example
333
432
  * flv.setRotate(90) // 旋转90度
334
433
  */
@@ -346,17 +445,6 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
346
445
  * flv.setKeepScreenOn()
347
446
  */
348
447
  setKeepScreenOn(): void;
349
- /**
350
- * @description 全屏(取消全屏)播放视频
351
- * @private
352
- * @param {Boolean} flag
353
- */
354
- private _setFullscreen;
355
- /**
356
- * 当前容器全屏中
357
- * @returns {boolean}
358
- */
359
- get fullscreening(): boolean;
360
448
  /**
361
449
  * 当前视频的信息, 推荐使用监听 videoInfo 事件
362
450
  * @returns {Object}
@@ -368,37 +456,7 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
368
456
  */
369
457
  get currentTime(): number;
370
458
  /**
371
- * @description 全屏播放视频(不支持移动端)
372
- * @returns {Promise}
373
- * @deprecated
374
- * @example
375
- * flv.fullScreen() // 全屏
376
- */
377
- fullScreen(): Promise<any>;
378
- /**
379
- * @description 全屏播放视频(不支持移动端)
380
- * @returns {Promise}
381
- * @example
382
- * flv.fullscreen() // 全屏
383
- */
384
- fullscreen(): Promise<any>;
385
- /**
386
- * @description 退出全屏播放视频
387
- * @returns {Promise}
388
- * @deprecated
389
- * @example
390
- * flv.cancelFullScreen() // 退出全屏
391
- */
392
- cancelFullScreen(): Promise<any>;
393
- /**
394
- * @description 取消全屏播放视频
395
- * @returns {Promise}
396
- * @example
397
- * flv.exitFullscreen() // 退出全屏
398
- */
399
- exitFullscreen(): Promise<any>;
400
- /**
401
- * @description 截图,调用后弹出下载框保存截图
459
+ * @description 截图,调用后弹出下载框保存截图, (硬解下 Mac Safari 部分截图结果是黑色的)
402
460
  * @param {string=} filename 保存的文件名, 默认 时间戳
403
461
  * @param {string=} format 截图的格式,可选png或jpeg或者webp ,默认 png
404
462
  * @param {number=} quality 当格式是jpeg或者webp时,压缩质量,取值0 ~ 1 ,默认 0.92
@@ -407,15 +465,15 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
407
465
  * @returns {string | Blob | undefined} undefined 代表截图失败
408
466
  * @since 1.0.3
409
467
  * @example
410
- * flv.screenshot()
411
- * flv.screenshot("filename", "jpeg", 0.7, "download")
468
+ * player.screenshot()
469
+ * player.screenshot("filename", "jpeg", 0.7, "download")
412
470
  */
413
471
  screenshot(filename?: string | undefined, format?: string | undefined, quality?: number | undefined, type?: ("download" | "base64" | "blob")): string | Blob | undefined;
414
472
  /**
415
473
  * @description 获取播放器的状态
416
474
  * @returns {PlayerState} 播放器的状态
417
475
  * @example
418
- * flv.getState()
476
+ * player.getState()
419
477
  */
420
478
  getState(): PlayerState;
421
479
  /**
@@ -435,7 +493,7 @@ declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
435
493
  */
436
494
  getVersion(): string;
437
495
  }
438
- import EventEmitter from 'eventemitter3';
496
+ import Theme from '@ezviz/player-theme';
439
497
  import Services from './services';
440
498
  import Events from './utils/events';
441
499
  import Player from './player';
@@ -0,0 +1,116 @@
1
+ declare const _default: {
2
+ 95000: string;
3
+ 95400: string;
4
+ 95402: string;
5
+ 95403: string;
6
+ 95404: string;
7
+ 95405: string;
8
+ 95406: string;
9
+ 95407: string;
10
+ 95409: string;
11
+ 95411: string;
12
+ 95412: string;
13
+ 95413: string;
14
+ 95415: string;
15
+ 95416: string;
16
+ 95417: string;
17
+ 95451: string;
18
+ 95452: string;
19
+ 95454: string;
20
+ 95455: string;
21
+ 95456: string;
22
+ 95457: string;
23
+ 95458: string;
24
+ 95459: string;
25
+ 95460: string;
26
+ 95461: string;
27
+ 95462: string;
28
+ 95463: string;
29
+ 95464: string;
30
+ 95465: string;
31
+ 95466: string;
32
+ 95492: string;
33
+ 95500: string;
34
+ 95503: string;
35
+ 95504: string;
36
+ 95505: string;
37
+ 95506: string;
38
+ 95507: string;
39
+ 95544: string;
40
+ 95545: string;
41
+ 95546: string;
42
+ 95547: string;
43
+ 95556: string;
44
+ 95557: string;
45
+ 95558: string;
46
+ 95560: string;
47
+ 95561: string;
48
+ 95562: string;
49
+ 95563: string;
50
+ 95564: string;
51
+ 95565: string;
52
+ 95566: string;
53
+ 95567: string;
54
+ 95568: string;
55
+ 95569: string;
56
+ 95600: string;
57
+ 95601: string;
58
+ 95602: string;
59
+ 95530: string;
60
+ 95610: string;
61
+ 95620: string;
62
+ 95701: string;
63
+ 95702: string;
64
+ 95703: string;
65
+ 96001: string;
66
+ 96002: string;
67
+ 96099: string;
68
+ 96101: string;
69
+ 96102: string;
70
+ 96103: string;
71
+ 96104: string;
72
+ 96105: string;
73
+ 96106: string;
74
+ 96107: string;
75
+ 96108: string;
76
+ 96109: string;
77
+ 96110: string;
78
+ 96501: string;
79
+ 96502: string;
80
+ 96503: string;
81
+ 96504: string;
82
+ 96505: string;
83
+ 96506: string;
84
+ 96508: string;
85
+ 96509: string;
86
+ 96510: string;
87
+ 96511: string;
88
+ 96512: string;
89
+ 96513: string;
90
+ 96514: string;
91
+ 96515: string;
92
+ 96516: string;
93
+ 96517: string;
94
+ 96518: string;
95
+ 96519: string;
96
+ 96520: string;
97
+ 90601: string;
98
+ 90602: string;
99
+ 90603: string;
100
+ 90604: string;
101
+ 90605: string;
102
+ 90606: string;
103
+ 4050: string;
104
+ 4054: string;
105
+ 4056: string;
106
+ 4057: string;
107
+ 4058: string;
108
+ 9048: string;
109
+ 9049: string;
110
+ 9053: string;
111
+ 9057: string;
112
+ 9060: string;
113
+ 9061: string;
114
+ 9062: string;
115
+ };
116
+ export default _default;
@@ -0,0 +1,116 @@
1
+ declare const _default: {
2
+ 95000: string;
3
+ 95400: string;
4
+ 95402: string;
5
+ 95403: string;
6
+ 95404: string;
7
+ 95405: string;
8
+ 95406: string;
9
+ 95407: string;
10
+ 95409: string;
11
+ 95411: string;
12
+ 95412: string;
13
+ 95413: string;
14
+ 95415: string;
15
+ 95416: string;
16
+ 95417: string;
17
+ 95451: string;
18
+ 95452: string;
19
+ 95454: string;
20
+ 95455: string;
21
+ 95456: string;
22
+ 95457: string;
23
+ 95458: string;
24
+ 95459: string;
25
+ 95460: string;
26
+ 95461: string;
27
+ 95462: string;
28
+ 95463: string;
29
+ 95464: string;
30
+ 95465: string;
31
+ 95466: string;
32
+ 95492: string;
33
+ 95500: string;
34
+ 95503: string;
35
+ 95504: string;
36
+ 95505: string;
37
+ 95506: string;
38
+ 95507: string;
39
+ 95544: string;
40
+ 95545: string;
41
+ 95546: string;
42
+ 95547: string;
43
+ 95556: string;
44
+ 95557: string;
45
+ 95558: string;
46
+ 95560: string;
47
+ 95561: string;
48
+ 95562: string;
49
+ 95563: string;
50
+ 95564: string;
51
+ 95565: string;
52
+ 95566: string;
53
+ 95567: string;
54
+ 95568: string;
55
+ 95569: string;
56
+ 95600: string;
57
+ 95601: string;
58
+ 95602: string;
59
+ 95530: string;
60
+ 95610: string;
61
+ 95620: string;
62
+ 95701: string;
63
+ 95702: string;
64
+ 95703: string;
65
+ 96001: string;
66
+ 96002: string;
67
+ 96099: string;
68
+ 96101: string;
69
+ 96102: string;
70
+ 96103: string;
71
+ 96104: string;
72
+ 96105: string;
73
+ 96106: string;
74
+ 96107: string;
75
+ 96108: string;
76
+ 96109: string;
77
+ 96110: string;
78
+ 96501: string;
79
+ 96502: string;
80
+ 96503: string;
81
+ 96504: string;
82
+ 96505: string;
83
+ 96506: string;
84
+ 96508: string;
85
+ 96509: string;
86
+ 96510: string;
87
+ 96511: string;
88
+ 96512: string;
89
+ 96513: string;
90
+ 96514: string;
91
+ 96515: string;
92
+ 96516: string;
93
+ 96517: string;
94
+ 96518: string;
95
+ 96519: string;
96
+ 96520: string;
97
+ 90601: string;
98
+ 90602: string;
99
+ 90603: string;
100
+ 90604: string;
101
+ 90605: string;
102
+ 90606: string;
103
+ 4050: string;
104
+ 4054: string;
105
+ 4056: string;
106
+ 4057: string;
107
+ 4058: string;
108
+ 9048: string;
109
+ 9049: string;
110
+ 9053: string;
111
+ 9057: string;
112
+ 9060: string;
113
+ 9061: string;
114
+ 9062: string;
115
+ };
116
+ export default _default;
@@ -1,14 +1,37 @@
1
+ import Emitter from '../utils/emitter';
2
+ import VideoLoader from './hard-player/videoLoader';
3
+ import CanvasLoader from './soft-player/canvasLoader';
4
+ import Debug from '../utils/debug';
5
+ import Events from '../utils/events';
6
+ import Control from '../control';
7
+ export interface PlayTimes {
8
+ playInitStart: number;
9
+ playStart: number;
10
+ streamStart: number;
11
+ streamResponse: number;
12
+ demuxStart: number;
13
+ decodeStart: number;
14
+ videoStart: number;
15
+ playTimestamp: number;
16
+ streamTimestamp: number;
17
+ streamResponseTimestamp: number;
18
+ demuxTimestamp: number;
19
+ decodeTimestamp: number;
20
+ videoTimestamp: number;
21
+ allTimestamp: number;
22
+ }
1
23
  export default class BasePlayer extends Emitter {
2
- constructor(container: any, options: any, Video: any);
3
- $container: any;
24
+ $container: Element;
4
25
  _opt: any;
5
26
  debug: Debug;
27
+ _muted: any;
28
+ _volume: any;
6
29
  _loading: boolean;
7
30
  _playing: boolean;
8
31
  _hasLoaded: boolean;
9
- _checkHeartTimeout: any;
10
- _checkStatsInterval: any;
11
- _startBpsTime: any;
32
+ _checkHeartTimeout: number | null;
33
+ _checkStatsInterval: number;
34
+ _startBpsTime: number;
12
35
  _isPlayingBeforePageHidden: boolean;
13
36
  _stats: {
14
37
  buf: number;
@@ -17,32 +40,21 @@ export default class BasePlayer extends Emitter {
17
40
  vbps: number;
18
41
  ts: number;
19
42
  };
20
- _times: {
21
- playInitStart: string;
22
- playStart: string;
23
- streamStart: string;
24
- streamResponse: string;
25
- demuxStart: string;
26
- decodeStart: string;
27
- videoStart: string;
28
- playTimestamp: string;
29
- streamTimestamp: string;
30
- streamResponseTimestamp: string;
31
- demuxTimestamp: string;
32
- decodeTimestamp: string;
33
- videoTimestamp: string;
34
- allTimestamp: string;
35
- };
43
+ _times: PlayTimes;
36
44
  _videoTimestamp: number;
37
45
  _audioTimestamp: number;
38
46
  events: Events;
39
- video: any;
47
+ video: VideoLoader | CanvasLoader;
40
48
  _fullscreen: boolean;
41
49
  control: Control;
42
- set fullscreen(value: any);
43
- get fullscreen(): any;
44
- set webFullscreen(value: any);
45
- get webFullscreen(): any;
50
+ constructor(container: Element, options: any, Video: new (player: BasePlayer) => VideoLoader | CanvasLoader);
51
+ get muted(): any;
52
+ set muted(muted: any);
53
+ protected _updateMuted(muted: boolean): void;
54
+ get volume(): any;
55
+ set volume(value: any);
56
+ protected _updateVolume(value: number): void;
57
+ destroy(): void;
46
58
  /**
47
59
  *
48
60
  * @param options
@@ -53,7 +65,3 @@ export default class BasePlayer extends Emitter {
53
65
  */
54
66
  resize(): void;
55
67
  }
56
- import Emitter from '../utils/emitter';
57
- import Debug from '../utils/debug';
58
- import Events from '../utils/events';
59
- import Control from '../control';