ezuikit-flv 1.0.1 → 1.0.2-alpha.10
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/CHANGELOG.md +9 -7
- package/README.md +1 -1
- package/decoder.js +2 -2
- package/index.js +14 -2
- package/package.json +15 -3
- package/types/constant/index.d.ts +4 -0
- package/types/index.d.ts +106 -38
- package/types/player/hard-player/index.d.ts +2 -3
- package/types/player/interface.d.ts +2 -0
- package/types/player/soft-player/index.d.ts +8 -8
- package/types/typedefs.d.ts +15 -0
- package/types/utils/debug.d.ts +3 -0
- package/types/utils/monitor.d.ts +13 -0
- package/types/utils/codec-support.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ezuikit-flv",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-alpha.10",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./types",
|
|
6
|
+
"author": "Ezviz-OpenBiz",
|
|
6
7
|
"files": [
|
|
7
8
|
"CHANGELOG.md",
|
|
8
9
|
"decoder.js",
|
|
@@ -12,9 +13,20 @@
|
|
|
12
13
|
"README.md",
|
|
13
14
|
"types"
|
|
14
15
|
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@ezuikit/player-base": "0.1.0-alpha.1",
|
|
18
|
+
"@ezuikit/utils-logger": "1.0.1",
|
|
19
|
+
"browser-tool": "^1.0.5",
|
|
20
|
+
"eventemitter3": "^5.0.1",
|
|
21
|
+
"recordrtc": "5.6.2",
|
|
22
|
+
"screenfull": "5.1.0"
|
|
23
|
+
},
|
|
15
24
|
"bugs": {
|
|
16
25
|
"url": "https://github.com/Ezviz-OpenBiz/EZUIKit-flv/issues"
|
|
17
26
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
27
|
+
"homepage": "https://github.com/Ezviz-OpenBiz/EZUIKit-flv",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public",
|
|
30
|
+
"registry": "https://registry.npmjs.org/"
|
|
31
|
+
}
|
|
20
32
|
}
|
|
@@ -29,6 +29,7 @@ export namespace DEFAULT_PLAYER_OPTIONS {
|
|
|
29
29
|
export let hasAudio: boolean;
|
|
30
30
|
export let hasVideo: boolean;
|
|
31
31
|
export let decoder: string;
|
|
32
|
+
export let staticPath: string;
|
|
32
33
|
export let url: string;
|
|
33
34
|
export let rotate: number;
|
|
34
35
|
export let forceNoOffscreen: boolean;
|
|
@@ -42,6 +43,9 @@ export namespace DEFAULT_PLAYER_OPTIONS {
|
|
|
42
43
|
export let openWebglAlignment: boolean;
|
|
43
44
|
export let wasmDecodeAudioSyncVideo: boolean;
|
|
44
45
|
export let useWebFullScreen: boolean;
|
|
46
|
+
export namespace loggerOptions {
|
|
47
|
+
let level: string;
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
export namespace WORKER_CMD_TYPE {
|
|
47
51
|
let init: string;
|
package/types/index.d.ts
CHANGED
|
@@ -2,9 +2,14 @@ export default EzuikitFlv;
|
|
|
2
2
|
/**
|
|
3
3
|
* @classdesc EzuikitFlv.js 播放flv直播流, 支持播放h264/h265的直播视频流
|
|
4
4
|
* @example
|
|
5
|
-
*
|
|
5
|
+
* ```js
|
|
6
|
+
* const flv = new EzuikitFlv({
|
|
7
|
+
* container: "EleId",
|
|
8
|
+
* url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv"
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
6
11
|
*/
|
|
7
|
-
declare class EzuikitFlv extends
|
|
12
|
+
declare class EzuikitFlv extends EventEmitter<string | symbol, any> {
|
|
8
13
|
/**
|
|
9
14
|
* @description ERROR
|
|
10
15
|
* @static
|
|
@@ -15,12 +20,7 @@ declare class EzuikitFlv extends Emitter {
|
|
|
15
20
|
static ERROR: {
|
|
16
21
|
playError: string;
|
|
17
22
|
fetchError: string;
|
|
18
|
-
websocketError: string;
|
|
19
|
-
* @description 开启声音 默认音量 0.5
|
|
20
|
-
* @returns {void}
|
|
21
|
-
* @example
|
|
22
|
-
* player.openSound() //
|
|
23
|
-
*/
|
|
23
|
+
websocketError: string;
|
|
24
24
|
webcodecsH265NotSupport: string;
|
|
25
25
|
webcodecsDecodeError: string;
|
|
26
26
|
webcodecsWidthOrHeightChange: string;
|
|
@@ -38,11 +38,36 @@ declare class EzuikitFlv extends Emitter {
|
|
|
38
38
|
loadingTimeout: string;
|
|
39
39
|
delayTimeout: string;
|
|
40
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
* @param {FlvOptions} options
|
|
44
|
+
* @returns {FlvOptions}
|
|
45
|
+
*/
|
|
46
|
+
private static _setOptions;
|
|
47
|
+
static version: string;
|
|
48
|
+
/**
|
|
49
|
+
* @description 静态方法 判断是否支持播放地址
|
|
50
|
+
* @param {Object} options
|
|
51
|
+
* @param {string=} options.url
|
|
52
|
+
* @param {type=} options.type
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
* @static
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```js
|
|
58
|
+
* EzuikitFlv.supportType({url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv", type:'flv'})
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
static supportType(options: {
|
|
62
|
+
url?: string | undefined;
|
|
63
|
+
type?: type | undefined;
|
|
64
|
+
}): boolean;
|
|
41
65
|
/**
|
|
42
66
|
* @constructor
|
|
43
67
|
* @param {FlvOptions} options
|
|
44
68
|
*/
|
|
45
69
|
constructor(options: FlvOptions);
|
|
70
|
+
event: EventEmitter<string | symbol, any>;
|
|
46
71
|
_opt: FlvOptions;
|
|
47
72
|
$container: any;
|
|
48
73
|
_loadingTimeoutReplayTimes: number;
|
|
@@ -51,7 +76,7 @@ declare class EzuikitFlv extends Emitter {
|
|
|
51
76
|
/**
|
|
52
77
|
* @description 销毁
|
|
53
78
|
* @example
|
|
54
|
-
*
|
|
79
|
+
* flv.destroy()
|
|
55
80
|
*/
|
|
56
81
|
destroy(): void;
|
|
57
82
|
player: Player;
|
|
@@ -79,21 +104,27 @@ declare class EzuikitFlv extends Emitter {
|
|
|
79
104
|
* @param {boolean} value true: 开启, false: 关闭
|
|
80
105
|
* @returns {void}
|
|
81
106
|
* @example
|
|
82
|
-
*
|
|
107
|
+
* flv.setDebug(false)
|
|
83
108
|
*/
|
|
84
109
|
setDebug(value: boolean): void;
|
|
110
|
+
/**
|
|
111
|
+
* @description 设置日志
|
|
112
|
+
* @param {object} options 日志设置 {level: 'INFO' | 'LOG' | 'WARN' | 'ERROR'}
|
|
113
|
+
* @returns {void}
|
|
114
|
+
*/
|
|
115
|
+
setLogger(opt?: {}): void;
|
|
85
116
|
/**
|
|
86
117
|
* @description 关闭声音
|
|
87
118
|
* @returns {void}
|
|
88
119
|
* @example
|
|
89
|
-
*
|
|
120
|
+
* flv.closeSound()
|
|
90
121
|
*/
|
|
91
122
|
closeSound(): void;
|
|
92
123
|
/**
|
|
93
124
|
* @description 开启声音 默认音量 0.5
|
|
94
125
|
* @returns {void}
|
|
95
126
|
* @example
|
|
96
|
-
*
|
|
127
|
+
* flv.openSound() //
|
|
97
128
|
*/
|
|
98
129
|
openSound(): void;
|
|
99
130
|
/**
|
|
@@ -101,23 +132,32 @@ declare class EzuikitFlv extends Emitter {
|
|
|
101
132
|
* @param {number} value 音量 0~1
|
|
102
133
|
* @returns {void}
|
|
103
134
|
* @example
|
|
104
|
-
*
|
|
135
|
+
* flv.setVolume(0.5)
|
|
105
136
|
*/
|
|
106
137
|
setVolume(value: number): void;
|
|
138
|
+
set volume(value: any);
|
|
139
|
+
get volume(): any;
|
|
107
140
|
/**
|
|
108
141
|
* @description 获取音量, 音量 0~1
|
|
109
142
|
* @returns {number}
|
|
110
143
|
* @example
|
|
111
|
-
*
|
|
144
|
+
* flv.getVolume()
|
|
112
145
|
*/
|
|
113
146
|
getVolume(): number;
|
|
147
|
+
/**
|
|
148
|
+
* @description 音频恢复
|
|
149
|
+
* @returns {void}
|
|
150
|
+
* @example
|
|
151
|
+
* flv.audioResume()
|
|
152
|
+
*/
|
|
153
|
+
audioResume(): void;
|
|
114
154
|
/**
|
|
115
155
|
* @description 设置超时时长, 单位秒 在连接成功之前和播放中途,如果超过设定时长无数据返回,则回调timeout事件
|
|
116
156
|
* @private
|
|
117
157
|
* @param {number} time 设置超时时长, 单位秒
|
|
118
158
|
* @returns {void}
|
|
119
159
|
* @example
|
|
120
|
-
*
|
|
160
|
+
* flv.setTimeout(3)
|
|
121
161
|
*/
|
|
122
162
|
private setTimeout;
|
|
123
163
|
/**
|
|
@@ -126,14 +166,14 @@ declare class EzuikitFlv extends Emitter {
|
|
|
126
166
|
* @param {0 | 1 | 2} type 0: 完全填充canvas区域; 1: 等比缩放, 最大边填充 ; 2: 等比缩放后,最小边填充,完全填充canvas区域,画面不被拉伸,没有黑边,但画面显示不全
|
|
127
167
|
* @returns {Promise}
|
|
128
168
|
* @example
|
|
129
|
-
*
|
|
169
|
+
* flv.setScaleMode(1)
|
|
130
170
|
*/
|
|
131
171
|
private setScaleMode;
|
|
132
172
|
/**
|
|
133
173
|
* @description 暂停
|
|
134
174
|
* @returns {Promise<unknown>}
|
|
135
175
|
* @example
|
|
136
|
-
*
|
|
176
|
+
* flv.pause()
|
|
137
177
|
*/
|
|
138
178
|
pause(): Promise<unknown>;
|
|
139
179
|
/**
|
|
@@ -141,7 +181,7 @@ declare class EzuikitFlv extends Emitter {
|
|
|
141
181
|
* @private
|
|
142
182
|
* @returns {void}
|
|
143
183
|
* @example
|
|
144
|
-
*
|
|
184
|
+
* flv.close()
|
|
145
185
|
*/
|
|
146
186
|
private close;
|
|
147
187
|
/**
|
|
@@ -149,17 +189,17 @@ declare class EzuikitFlv extends Emitter {
|
|
|
149
189
|
* @private
|
|
150
190
|
* @returns {void}
|
|
151
191
|
* @example
|
|
152
|
-
*
|
|
192
|
+
* flv.clearView()
|
|
153
193
|
*/
|
|
154
194
|
private clearView;
|
|
155
195
|
/**
|
|
156
196
|
* @description 播放
|
|
157
|
-
* @param {FlvOptions=} options
|
|
197
|
+
* @param {(string | FlvOptions)=} options
|
|
158
198
|
* @returns {Promise}
|
|
159
199
|
* @example
|
|
160
|
-
*
|
|
200
|
+
* flv.play()
|
|
161
201
|
*/
|
|
162
|
-
play(options?: FlvOptions): Promise<any>;
|
|
202
|
+
play(options?: (string | FlvOptions) | undefined): Promise<any>;
|
|
163
203
|
/**
|
|
164
204
|
* @description 播放
|
|
165
205
|
* @private
|
|
@@ -170,27 +210,28 @@ declare class EzuikitFlv extends Emitter {
|
|
|
170
210
|
private _play;
|
|
171
211
|
/**
|
|
172
212
|
* @description 重新调整视图大小
|
|
173
|
-
* @
|
|
213
|
+
* @param {number=} width 宽
|
|
214
|
+
* @param {number=} height 高
|
|
174
215
|
* @example
|
|
175
|
-
*
|
|
216
|
+
* flv.resize()
|
|
176
217
|
*/
|
|
177
|
-
|
|
218
|
+
resize(width?: number | undefined, height?: number | undefined): void;
|
|
178
219
|
/**
|
|
179
220
|
* @description 设置最大缓冲时长,单位秒,播放器会自动消除延迟。软解
|
|
180
221
|
* @private
|
|
181
222
|
* @param {number} time 大缓冲时长 s
|
|
182
223
|
* @example
|
|
183
|
-
*
|
|
224
|
+
* flv.setBufferTime(3)
|
|
184
225
|
*/
|
|
185
226
|
private setBufferTime;
|
|
186
227
|
/**
|
|
187
228
|
* @description 设置旋转角度,支持,0(默认), 90, 180, 270 四个值。
|
|
188
|
-
* @param {0 | 90 | 180 | 270} deg 旋转角度
|
|
189
229
|
* @returns {Promise}
|
|
230
|
+
* @param {number} deg
|
|
190
231
|
* @example
|
|
191
|
-
*
|
|
232
|
+
* flv.setRotate(90) // 旋转90度
|
|
192
233
|
*/
|
|
193
|
-
setRotate(deg:
|
|
234
|
+
setRotate(deg: number): Promise<any>;
|
|
194
235
|
/**
|
|
195
236
|
* @description 返回是否加载完毕
|
|
196
237
|
* @private
|
|
@@ -201,7 +242,7 @@ declare class EzuikitFlv extends Emitter {
|
|
|
201
242
|
* @description 开启屏幕常亮,在手机浏览器上
|
|
202
243
|
* @returns {void}
|
|
203
244
|
* @example
|
|
204
|
-
*
|
|
245
|
+
* flv.setKeepScreenOn()
|
|
205
246
|
*/
|
|
206
247
|
setKeepScreenOn(): void;
|
|
207
248
|
/**
|
|
@@ -212,31 +253,58 @@ declare class EzuikitFlv extends Emitter {
|
|
|
212
253
|
private _setFullscreen;
|
|
213
254
|
/**
|
|
214
255
|
* @description 全屏播放视频
|
|
256
|
+
* @returns {Promise}
|
|
215
257
|
* @example
|
|
216
|
-
*
|
|
258
|
+
* flv.fullScreen() // 全屏
|
|
259
|
+
*
|
|
217
260
|
*/
|
|
218
|
-
fullScreen():
|
|
261
|
+
fullScreen(): Promise<any>;
|
|
262
|
+
/**
|
|
263
|
+
* @description 全屏播放视频
|
|
264
|
+
* @returns {Promise}
|
|
265
|
+
* @example
|
|
266
|
+
* flv.fullscreen() // 全屏
|
|
267
|
+
*
|
|
268
|
+
*/
|
|
269
|
+
fullscreen(): Promise<any>;
|
|
270
|
+
/**
|
|
271
|
+
* @description 退出全屏播放视频
|
|
272
|
+
* @returns {Promise}
|
|
273
|
+
* @example
|
|
274
|
+
* flv.cancelFullScreen() // 退出全屏
|
|
275
|
+
*/
|
|
276
|
+
cancelFullScreen(): Promise<any>;
|
|
219
277
|
/**
|
|
220
278
|
* @description 取消全屏播放视频
|
|
279
|
+
* @returns {Promise}
|
|
221
280
|
* @example
|
|
222
|
-
*
|
|
281
|
+
* flv.exitFullscreen() // 全屏
|
|
282
|
+
*/
|
|
283
|
+
exitFullscreen(): Promise<any>;
|
|
284
|
+
/**
|
|
285
|
+
* @description 退出全屏播放视频
|
|
286
|
+
* @private
|
|
287
|
+
* @returns {Promise}
|
|
223
288
|
*/
|
|
224
|
-
|
|
289
|
+
private _exitFullscreen;
|
|
225
290
|
/**
|
|
226
291
|
* @description 获取播放器的状态
|
|
227
292
|
* @returns {PlayerState} 播放器的状态
|
|
228
293
|
* @example
|
|
229
|
-
*
|
|
294
|
+
* flv.getState()
|
|
230
295
|
*/
|
|
231
296
|
getState(): PlayerState;
|
|
297
|
+
/**
|
|
298
|
+
* @description 获取设置
|
|
299
|
+
* @returns {object}
|
|
300
|
+
*/
|
|
301
|
+
getOptions(): object;
|
|
232
302
|
/**
|
|
233
303
|
* @description 获取版本
|
|
234
304
|
* @returns {string}
|
|
235
|
-
* @example
|
|
236
|
-
* player.getVersion()
|
|
237
305
|
*/
|
|
238
306
|
getVersion(): string;
|
|
239
307
|
}
|
|
240
|
-
import
|
|
308
|
+
import EventEmitter from 'eventemitter3';
|
|
241
309
|
import Events from './utils/events';
|
|
242
310
|
import Player from './player';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { PlayerInterface } from '../interface';
|
|
1
|
+
import { type PlayerInterface, type RequiredFlvOptions } from '../interface';
|
|
2
2
|
import Events from '../../utils/events';
|
|
3
3
|
import Video from './videoLoader';
|
|
4
|
-
import Control from '../../control';
|
|
5
|
-
import { RequiredFlvOptions } from '../interface';
|
|
4
|
+
import type Control from '../../control';
|
|
6
5
|
import BasePlayer from '../base-player';
|
|
7
6
|
/**
|
|
8
7
|
* @class
|
|
@@ -7,22 +7,22 @@ export default class SoftPlayer extends BasePlayer {
|
|
|
7
7
|
_lastVolume: any;
|
|
8
8
|
keepScreenOn: NoSleep;
|
|
9
9
|
destroy(): void;
|
|
10
|
-
set fullscreen(
|
|
10
|
+
set fullscreen(value: any);
|
|
11
11
|
get fullscreen(): any;
|
|
12
|
-
set webFullscreen(
|
|
12
|
+
set webFullscreen(value: any);
|
|
13
13
|
get webFullscreen(): any;
|
|
14
|
-
set loaded(
|
|
14
|
+
set loaded(value: boolean);
|
|
15
15
|
get loaded(): boolean;
|
|
16
|
-
set playing(
|
|
16
|
+
set playing(value: boolean);
|
|
17
17
|
get playing(): boolean;
|
|
18
|
-
set loading(
|
|
18
|
+
set loading(value: boolean);
|
|
19
19
|
get loading(): boolean;
|
|
20
|
-
set volume(
|
|
20
|
+
set volume(value: any);
|
|
21
21
|
get volume(): any;
|
|
22
22
|
get lastVolume(): any;
|
|
23
|
-
set audioTimestamp(
|
|
23
|
+
set audioTimestamp(value: number);
|
|
24
24
|
get audioTimestamp(): number;
|
|
25
|
-
set videoTimestamp(
|
|
25
|
+
set videoTimestamp(value: number);
|
|
26
26
|
get videoTimestamp(): number;
|
|
27
27
|
get isDebug(): boolean;
|
|
28
28
|
/**
|
package/types/typedefs.d.ts
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* @typedef FlvOptions
|
|
5
5
|
*
|
|
6
6
|
* @property {string | HTMLElement} container 渲染容器
|
|
7
|
+
* @property {string } id 渲染容器id 优先级比 container 高
|
|
7
8
|
* @property {number=} videoBuffer 设置最大缓冲时长,单位秒,播放器会自动消除延迟。
|
|
8
9
|
* @property {string=} decoder 解码库worker地址 默认 `decoder.js`, wasm 文件要和decoder在同一个文件夹中
|
|
10
|
+
* @property {string=} staticPath 静态资源的了路径
|
|
11
|
+
* @property {boolean=} autoPlay 自动播放 默认false
|
|
9
12
|
* @property {boolean=} hasAudio 是否有音频,如果设置false,则不对音频数据解码,提升性能。
|
|
10
13
|
* @property {(0 | 1 | 2)=} scaleMode 设置渲染模式, 默认 1, 取值 0 | 1 | 2。
|
|
11
14
|
* @property {boolean=} debug 是否开启控制台调试打印。默认 false
|
|
@@ -39,6 +42,10 @@ export type FlvOptions = {
|
|
|
39
42
|
* 渲染容器
|
|
40
43
|
*/
|
|
41
44
|
container: string | HTMLElement;
|
|
45
|
+
/**
|
|
46
|
+
* 渲染容器id 优先级比 container 高
|
|
47
|
+
*/
|
|
48
|
+
id: string;
|
|
42
49
|
/**
|
|
43
50
|
* 设置最大缓冲时长,单位秒,播放器会自动消除延迟。
|
|
44
51
|
*/
|
|
@@ -47,6 +54,14 @@ export type FlvOptions = {
|
|
|
47
54
|
* 解码库worker地址 默认 `decoder.js`, wasm 文件要和decoder在同一个文件夹中
|
|
48
55
|
*/
|
|
49
56
|
decoder?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* 静态资源的了路径
|
|
59
|
+
*/
|
|
60
|
+
staticPath?: string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* 自动播放 默认false
|
|
63
|
+
*/
|
|
64
|
+
autoPlay?: boolean | undefined;
|
|
50
65
|
/**
|
|
51
66
|
* 是否有音频,如果设置false,则不对音频数据解码,提升性能。
|
|
52
67
|
*/
|
package/types/utils/debug.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export default class Debug {
|
|
2
2
|
constructor(master: any);
|
|
3
3
|
master: any;
|
|
4
|
+
logger: any;
|
|
5
|
+
info(name: any, ...args: any[]): void;
|
|
4
6
|
log(name: any, ...args: any[]): void;
|
|
5
7
|
warn(name: any, ...args: any[]): void;
|
|
6
8
|
error(name: any, ...args: any[]): void;
|
|
9
|
+
_setLoger(level: any): 1 | 2 | 3 | 4 | 5;
|
|
7
10
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default Monitor;
|
|
2
|
+
/**
|
|
3
|
+
* /pages/viewpage.action?pageId=663566571
|
|
4
|
+
*/
|
|
5
|
+
declare class Monitor {
|
|
6
|
+
static initMonitor(ignoreMonitor: any): void;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {1 | 2 | 3 | 50 | 51 | 100} type 1: 初始化 2: 播放成功 3: 播放异常 50: api 调用 51:错误回调 100: 接口上报
|
|
10
|
+
* @param {ReportData} logInfo
|
|
11
|
+
*/
|
|
12
|
+
static report(action: any, logInfo?: ReportData): void;
|
|
13
|
+
}
|