ezuikit-flv 1.0.0-alpha.1 → 1.0.2-alpha.1
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 +15 -7
- package/README.md +33 -33
- package/decoder.js +1 -1
- package/index.js +14 -10
- package/package.json +8 -3
- package/types/flv-mse/flv.min.d.ts +0 -1
- package/types/index.d.ts +28 -11
- package/types/player/base-player.d.ts +5 -0
- package/types/player/hard-player/index.d.ts +4 -5
- package/types/player/soft-player/canvasLoader.d.ts +1 -0
- package/types/player/soft-player/index.d.ts +11 -16
- package/types/typedefs.d.ts +1 -16
- package/types/utils/debug.d.ts +4 -3
- package/types/utils/monitor.d.ts +7 -16
- 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.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./types",
|
|
6
|
+
"author": "Ezviz-OpenBiz",
|
|
6
7
|
"files": [
|
|
7
8
|
"CHANGELOG.md",
|
|
8
9
|
"decoder.js",
|
|
@@ -11,5 +12,9 @@
|
|
|
11
12
|
"package.json",
|
|
12
13
|
"README.md",
|
|
13
14
|
"types"
|
|
14
|
-
]
|
|
15
|
-
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,12 @@ 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
12
|
declare class EzuikitFlv extends Emitter {
|
|
8
13
|
/**
|
|
@@ -18,13 +23,7 @@ declare class EzuikitFlv extends Emitter {
|
|
|
18
23
|
websocketError: string;
|
|
19
24
|
webcodecsH265NotSupport: string;
|
|
20
25
|
webcodecsDecodeError: string;
|
|
21
|
-
webcodecsWidthOrHeightChange: string;
|
|
22
|
-
* @description 设置音量
|
|
23
|
-
* @param {number} value 音量 0~1
|
|
24
|
-
* @returns {void}
|
|
25
|
-
* @example
|
|
26
|
-
* flv.setVolume(0.5)
|
|
27
|
-
*/
|
|
26
|
+
webcodecsWidthOrHeightChange: string;
|
|
28
27
|
mediaSourceH265NotSupport: string;
|
|
29
28
|
mediaSourceFull: string;
|
|
30
29
|
mseSourceBufferError: string;
|
|
@@ -39,6 +38,24 @@ declare class EzuikitFlv extends Emitter {
|
|
|
39
38
|
loadingTimeout: string;
|
|
40
39
|
delayTimeout: string;
|
|
41
40
|
};
|
|
41
|
+
static version: string;
|
|
42
|
+
/**
|
|
43
|
+
* @description 静态方法 判断是否支持播放地址
|
|
44
|
+
* @param {Object} options
|
|
45
|
+
* @param {string=} options.url
|
|
46
|
+
* @param {type=} options.type
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
* @static
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```js
|
|
52
|
+
* EzuikitFlv.supportType({url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv", type:'flv'})
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
static supportType(options: {
|
|
56
|
+
url?: string | undefined;
|
|
57
|
+
type?: type | undefined;
|
|
58
|
+
}): boolean;
|
|
42
59
|
/**
|
|
43
60
|
* @constructor
|
|
44
61
|
* @param {FlvOptions} options
|
|
@@ -162,12 +179,12 @@ declare class EzuikitFlv extends Emitter {
|
|
|
162
179
|
private clearView;
|
|
163
180
|
/**
|
|
164
181
|
* @description 播放
|
|
165
|
-
* @param {
|
|
182
|
+
* @param {FlvOptions=} options
|
|
166
183
|
* @returns {Promise}
|
|
167
184
|
* @example
|
|
168
185
|
* flv.play()
|
|
169
186
|
*/
|
|
170
|
-
play(options?:
|
|
187
|
+
play(options?: FlvOptions): Promise<any>;
|
|
171
188
|
/**
|
|
172
189
|
* @description 播放
|
|
173
190
|
* @private
|
|
@@ -184,7 +201,7 @@ declare class EzuikitFlv extends Emitter {
|
|
|
184
201
|
*/
|
|
185
202
|
private resize;
|
|
186
203
|
/**
|
|
187
|
-
* @description
|
|
204
|
+
* @description 设置最大缓冲时长,单位秒,播放器会自动消除延迟。软解
|
|
188
205
|
* @private
|
|
189
206
|
* @param {number} time 大缓冲时长 s
|
|
190
207
|
* @example
|
|
@@ -39,6 +39,11 @@ export default class BasePlayer extends Emitter {
|
|
|
39
39
|
events: Events;
|
|
40
40
|
video: any;
|
|
41
41
|
control: Control;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param options
|
|
45
|
+
*/
|
|
46
|
+
updateOption(options: any): void;
|
|
42
47
|
}
|
|
43
48
|
import Emitter from '../utils/emitter';
|
|
44
49
|
import Debug from '../utils/debug';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { PlayerInterface } from '../interface';
|
|
2
|
-
import Debug from '../../utils/debug';
|
|
1
|
+
import { type PlayerInterface, type RequiredFlvOptions } from '../interface';
|
|
3
2
|
import Events from '../../utils/events';
|
|
4
3
|
import Video from './videoLoader';
|
|
5
|
-
import Control from '../../control';
|
|
6
|
-
import { RequiredFlvOptions } from '../interface';
|
|
4
|
+
import type Control from '../../control';
|
|
7
5
|
import BasePlayer from '../base-player';
|
|
8
6
|
/**
|
|
9
7
|
* @class
|
|
@@ -22,7 +20,6 @@ export default class HardPlayer extends BasePlayer implements PlayerInterface {
|
|
|
22
20
|
_times: any;
|
|
23
21
|
$container: HTMLElement;
|
|
24
22
|
_opt: RequiredFlvOptions;
|
|
25
|
-
debug: Debug;
|
|
26
23
|
_hasLoaded: boolean;
|
|
27
24
|
_checkHeartTimeout: number;
|
|
28
25
|
_stats: any;
|
|
@@ -30,6 +27,8 @@ export default class HardPlayer extends BasePlayer implements PlayerInterface {
|
|
|
30
27
|
control: Control;
|
|
31
28
|
width: number;
|
|
32
29
|
height: number;
|
|
30
|
+
_pause: boolean;
|
|
31
|
+
_decodedFrames: number;
|
|
33
32
|
constructor(container: HTMLElement, options: RequiredFlvOptions);
|
|
34
33
|
close(): Promise<unknown>;
|
|
35
34
|
_createPlayer(options: RequiredFlvOptions): void;
|
|
@@ -7,29 +7,24 @@ 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
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param options
|
|
31
|
-
*/
|
|
32
|
-
updateOption(options: any): void;
|
|
33
28
|
/**
|
|
34
29
|
*
|
|
35
30
|
* @returns {Promise<unknown>}
|
|
@@ -45,7 +40,7 @@ export default class SoftPlayer extends BasePlayer {
|
|
|
45
40
|
*
|
|
46
41
|
*/
|
|
47
42
|
close(): Promise<any>;
|
|
48
|
-
|
|
43
|
+
_resumeAudioAfterPause(): void;
|
|
49
44
|
_close(): Promise<any>;
|
|
50
45
|
/**
|
|
51
46
|
*
|
|
@@ -55,9 +50,9 @@ export default class SoftPlayer extends BasePlayer {
|
|
|
55
50
|
pause(flag?: boolean): Promise<unknown>;
|
|
56
51
|
/**
|
|
57
52
|
* @description 静音
|
|
58
|
-
* @param flag
|
|
53
|
+
* @param {boolean} flag
|
|
59
54
|
*/
|
|
60
|
-
mute(flag:
|
|
55
|
+
mute(flag: boolean): void;
|
|
61
56
|
/**
|
|
62
57
|
* @description 重置尺寸
|
|
63
58
|
*/
|
package/types/typedefs.d.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @property {string | HTMLElement} container 渲染容器
|
|
7
7
|
* @property {number=} videoBuffer 设置最大缓冲时长,单位秒,播放器会自动消除延迟。
|
|
8
8
|
* @property {string=} decoder 解码库worker地址 默认 `decoder.js`, wasm 文件要和decoder在同一个文件夹中
|
|
9
|
-
* @property {boolean=} forceNoOffscreen 是否不使用离屏模式(提升渲染能力)
|
|
10
9
|
* @property {boolean=} hasAudio 是否有音频,如果设置false,则不对音频数据解码,提升性能。
|
|
11
10
|
* @property {(0 | 1 | 2)=} scaleMode 设置渲染模式, 默认 1, 取值 0 | 1 | 2。
|
|
12
11
|
* @property {boolean=} debug 是否开启控制台调试打印。默认 false
|
|
@@ -19,13 +18,11 @@
|
|
|
19
18
|
* @property {boolean=} isNotMute 是否开启声音,默认是关闭声音播放的。默认 false
|
|
20
19
|
* @property {boolean=} useMSE 是否开启MediaSource硬解码。视频编码只支持H.264视频(Safari on iOS不支持)。默认 false
|
|
21
20
|
* @property {boolean=} autoWasm 在使用MSE或者Webcodecs 播放H265的时候,是否自动降级到wasm模式。默认 true
|
|
22
|
-
* @property {boolean=} wasmDecodeErrorReplay 是否开启解码失败重新播放。默认 true
|
|
23
|
-
* @property {boolean=} useWebFullScreen 是否使用web全屏(旋转90度)(只会在移动端生效)。默认 false
|
|
24
21
|
*
|
|
25
22
|
*/
|
|
26
23
|
/**
|
|
27
24
|
*
|
|
28
|
-
* @description 播放器的状态
|
|
25
|
+
* @description 播放器的状态 (getState() api)
|
|
29
26
|
* @typedef PlayerState
|
|
30
27
|
*
|
|
31
28
|
* @property {boolean} playing 是否正在播放
|
|
@@ -50,10 +47,6 @@ export type FlvOptions = {
|
|
|
50
47
|
* 解码库worker地址 默认 `decoder.js`, wasm 文件要和decoder在同一个文件夹中
|
|
51
48
|
*/
|
|
52
49
|
decoder?: string | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* 是否不使用离屏模式(提升渲染能力)
|
|
55
|
-
*/
|
|
56
|
-
forceNoOffscreen?: boolean | undefined;
|
|
57
50
|
/**
|
|
58
51
|
* 是否有音频,如果设置false,则不对音频数据解码,提升性能。
|
|
59
52
|
*/
|
|
@@ -102,14 +95,6 @@ export type FlvOptions = {
|
|
|
102
95
|
* 在使用MSE或者Webcodecs 播放H265的时候,是否自动降级到wasm模式。默认 true
|
|
103
96
|
*/
|
|
104
97
|
autoWasm?: boolean | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* 是否开启解码失败重新播放。默认 true
|
|
107
|
-
*/
|
|
108
|
-
wasmDecodeErrorReplay?: boolean | undefined;
|
|
109
|
-
/**
|
|
110
|
-
* 是否使用web全屏(旋转90度)(只会在移动端生效)。默认 false
|
|
111
|
-
*/
|
|
112
|
-
useWebFullScreen?: boolean | undefined;
|
|
113
98
|
};
|
|
114
99
|
export type PlayerState = {
|
|
115
100
|
/**
|
package/types/utils/debug.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default class Debug {
|
|
2
2
|
constructor(master: any);
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
master: any;
|
|
4
|
+
log(name: any, ...args: any[]): void;
|
|
5
|
+
warn(name: any, ...args: any[]): void;
|
|
6
|
+
error(name: any, ...args: any[]): void;
|
|
6
7
|
}
|
package/types/utils/monitor.d.ts
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
export default Monitor;
|
|
2
|
+
/**
|
|
3
|
+
* /pages/viewpage.action?pageId=663566571
|
|
4
|
+
*/
|
|
2
5
|
declare class Monitor {
|
|
3
|
-
static
|
|
4
|
-
static initMonitor(): void;
|
|
5
|
-
/**
|
|
6
|
-
* @typedef ReportData
|
|
7
|
-
* @property {string} event 事件名称 error | play | pause | openSound | closeSound | fullScreen | cancelFullScreen | setDebug | setKeepScreenOn | setVolume | setRotate | getState | getVersion
|
|
8
|
-
* @property {*} value
|
|
9
|
-
*/
|
|
6
|
+
static initMonitor(ignoreMonitor: any): void;
|
|
10
7
|
/**
|
|
11
8
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {ReportData}
|
|
9
|
+
* @param {1 | 2 | 3 | 50 | 51 | 100} type 1: 初始化 2: 播放成功 3: 播放异常 50: api 调用 51:错误回调 100: 接口上报
|
|
10
|
+
* @param {ReportData} logInfo
|
|
14
11
|
*/
|
|
15
|
-
static report(
|
|
16
|
-
/**
|
|
17
|
-
* 事件名称 error | play | pause | openSound | closeSound | fullScreen | cancelFullScreen | setDebug | setKeepScreenOn | setVolume | setRotate | getState | getVersion
|
|
18
|
-
*/
|
|
19
|
-
event: string;
|
|
20
|
-
value: any;
|
|
21
|
-
}): void;
|
|
12
|
+
static report(action: any, logInfo?: ReportData): void;
|
|
22
13
|
}
|