ezuikit-flv 1.0.2-alpha.6 → 1.0.2-alpha.7
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/decoder.js +6 -0
- package/decoder.wasm +0 -0
- package/index.js +18 -0
- package/package.json +23 -84
- package/types/audio/audioContextLoader.d.ts +42 -0
- package/types/audio/index.d.ts +5 -0
- package/types/constant/index.d.ts +264 -0
- package/types/control/index.d.ts +4 -0
- package/types/control/observer.d.ts +2 -0
- package/types/demux/commonLoader.d.ts +19 -0
- package/types/demux/flvLoader.d.ts +15 -0
- package/types/demux/index.d.ts +5 -0
- package/types/demux/m7sLoader.d.ts +4 -0
- package/types/flv-mse/flv.min.d.ts +3 -0
- package/types/index.d.ts +290 -0
- package/types/player/base-player.d.ts +51 -0
- package/types/player/commonLoader.d.ts +16 -0
- package/types/player/events.d.ts +2 -0
- package/types/player/hard-player/index.d.ts +94 -0
- package/types/player/hard-player/videoLoader.d.ts +28 -0
- package/types/player/index.d.ts +7 -0
- package/types/player/interface.d.ts +100 -0
- package/types/player/observer.d.ts +2 -0
- package/types/player/property.d.ts +2 -0
- package/types/player/soft-player/canvasLoader.d.ts +27 -0
- package/types/player/soft-player/index.d.ts +91 -0
- package/types/stream/fetchLoader.d.ts +16 -0
- package/types/stream/index.d.ts +6 -0
- package/types/stream/websocketLoader.d.ts +18 -0
- package/types/typedefs.d.ts +138 -0
- package/types/utils/debug.d.ts +8 -0
- package/types/utils/emitter.d.ts +7 -0
- package/types/utils/events.d.ts +7 -0
- package/types/utils/file-save.d.ts +2 -0
- package/types/utils/index.d.ts +70 -0
- package/types/utils/monitor.d.ts +13 -0
- package/types/utils/noSleep.d.ts +12 -0
- package/types/utils/parse-url.d.ts +5 -0
- package/types/utils/webgl.d.ts +5 -0
- package/types/worker/index.d.ts +13 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
export default EzuikitFlv;
|
|
2
|
+
/**
|
|
3
|
+
* @classdesc EzuikitFlv.js 播放flv直播流, 支持播放h264/h265的直播视频流
|
|
4
|
+
* @example
|
|
5
|
+
* ```js
|
|
6
|
+
* const flv = new EzuikitFlv({
|
|
7
|
+
* container: "EleId",
|
|
8
|
+
* url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv"
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
declare class EzuikitFlv extends BasePlayer {
|
|
13
|
+
/**
|
|
14
|
+
* @description ERROR
|
|
15
|
+
* @static
|
|
16
|
+
* @member
|
|
17
|
+
* @example
|
|
18
|
+
* EzuikitFlv.ERROR.playError
|
|
19
|
+
*/
|
|
20
|
+
static ERROR: {
|
|
21
|
+
playError: string;
|
|
22
|
+
fetchError: string;
|
|
23
|
+
websocketError: string;
|
|
24
|
+
webcodecsH265NotSupport: string;
|
|
25
|
+
webcodecsDecodeError: string;
|
|
26
|
+
webcodecsWidthOrHeightChange: string;
|
|
27
|
+
mediaSourceH265NotSupport: string;
|
|
28
|
+
mediaSourceFull: string;
|
|
29
|
+
mseSourceBufferError: string;
|
|
30
|
+
mediaSourceAppendBufferError: string;
|
|
31
|
+
mediaSourceBufferListLarge: string;
|
|
32
|
+
mediaSourceAppendBufferEndTimeout: string;
|
|
33
|
+
wasmDecodeError: string; /**
|
|
34
|
+
* @description 绑定事件
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
webglAlignmentError: string;
|
|
38
|
+
};
|
|
39
|
+
/** */
|
|
40
|
+
static TIMEOUT: {
|
|
41
|
+
loadingTimeout: string;
|
|
42
|
+
delayTimeout: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* @param {FlvOptions} options
|
|
47
|
+
* @returns {FlvOptions}
|
|
48
|
+
*/
|
|
49
|
+
private static _setOptions;
|
|
50
|
+
static version: string;
|
|
51
|
+
/**
|
|
52
|
+
* @description 静态方法 判断是否支持播放地址
|
|
53
|
+
* @param {Object} options
|
|
54
|
+
* @param {string=} options.url
|
|
55
|
+
* @param {type=} options.type
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
* @static
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```js
|
|
61
|
+
* EzuikitFlv.supportType({url: "https://open.ys7.com/v3/openlive/E71992743_1_1.flv", type:'flv'})
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
static supportType(options: {
|
|
65
|
+
url?: string | undefined;
|
|
66
|
+
type?: type | undefined;
|
|
67
|
+
}): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @constructor
|
|
70
|
+
* @param {FlvOptions} options
|
|
71
|
+
*/
|
|
72
|
+
constructor(options: FlvOptions);
|
|
73
|
+
event: {
|
|
74
|
+
on: <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => this;
|
|
75
|
+
emit: <T_1 extends string | symbol>(event: T_1, ...args: any[]) => boolean;
|
|
76
|
+
eventNames: () => (string | symbol)[];
|
|
77
|
+
listeners: <T_2 extends string | symbol>(event: T_2) => ((...args: any[]) => void)[];
|
|
78
|
+
off: <T_3 extends string | symbol>(event: T_3, fn?: (...args: any[]) => void, context?: any, once?: boolean) => this;
|
|
79
|
+
once: <T_4 extends string | symbol>(event: T_4, fn: (...args: any[]) => void, context?: any) => this;
|
|
80
|
+
listenerCount: (event: string | symbol) => number;
|
|
81
|
+
addListener: <T_5 extends string | symbol>(event: T_5, fn: (...args: any[]) => void, context?: any) => this;
|
|
82
|
+
removeListener: <T_6 extends string | symbol>(event: T_6, fn?: (...args: any[]) => void, context?: any, once?: boolean) => this;
|
|
83
|
+
removeAllListeners: (event?: string | symbol) => this;
|
|
84
|
+
};
|
|
85
|
+
_opt: FlvOptions;
|
|
86
|
+
$container: any;
|
|
87
|
+
_loadingTimeoutReplayTimes: number;
|
|
88
|
+
_heartTimeoutReplayTimes: number;
|
|
89
|
+
events: Events;
|
|
90
|
+
player: Player;
|
|
91
|
+
/**
|
|
92
|
+
* @description 初始化播放
|
|
93
|
+
* @private
|
|
94
|
+
* @param {string | HTMLElement} $container
|
|
95
|
+
* @param {FlvOptions} options
|
|
96
|
+
* @return {void}
|
|
97
|
+
*/
|
|
98
|
+
private _initPlayer;
|
|
99
|
+
/**
|
|
100
|
+
* @description 重置播放器
|
|
101
|
+
* @private
|
|
102
|
+
* @param {FlvOptions} options
|
|
103
|
+
*/
|
|
104
|
+
private _resetPlayer;
|
|
105
|
+
/**
|
|
106
|
+
* @description 绑定事件
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
private _bindEvents;
|
|
110
|
+
/**
|
|
111
|
+
* @description 是否开启控制台调试打印
|
|
112
|
+
* @param {boolean} value true: 开启, false: 关闭
|
|
113
|
+
* @returns {void}
|
|
114
|
+
* @example
|
|
115
|
+
* flv.setDebug(false)
|
|
116
|
+
*/
|
|
117
|
+
setDebug(value: boolean): void;
|
|
118
|
+
/**
|
|
119
|
+
* @description 设置日志
|
|
120
|
+
* @param {object} options 日志设置 {level: 'INFO' | 'LOG' | 'WARN' | 'ERROR'}
|
|
121
|
+
* @returns {void}
|
|
122
|
+
*/
|
|
123
|
+
setLogger(opt?: {}): void;
|
|
124
|
+
/**
|
|
125
|
+
* @description 关闭声音
|
|
126
|
+
* @returns {void}
|
|
127
|
+
* @example
|
|
128
|
+
* flv.closeSound()
|
|
129
|
+
*/
|
|
130
|
+
closeSound(): void;
|
|
131
|
+
/**
|
|
132
|
+
* @description 开启声音 默认音量 0.5
|
|
133
|
+
* @returns {void}
|
|
134
|
+
* @example
|
|
135
|
+
* flv.openSound() //
|
|
136
|
+
*/
|
|
137
|
+
openSound(): void;
|
|
138
|
+
set volume(value: any);
|
|
139
|
+
get volume(): any;
|
|
140
|
+
/**
|
|
141
|
+
* @description 获取音量, 音量 0~1
|
|
142
|
+
* @returns {number}
|
|
143
|
+
* @example
|
|
144
|
+
* flv.getVolume()
|
|
145
|
+
*/
|
|
146
|
+
getVolume(): number;
|
|
147
|
+
/**
|
|
148
|
+
* @description 音频回复
|
|
149
|
+
* @returns {void}
|
|
150
|
+
* @example
|
|
151
|
+
* flv.audioResume()
|
|
152
|
+
*/
|
|
153
|
+
audioResume(): void;
|
|
154
|
+
/**
|
|
155
|
+
* @description 设置超时时长, 单位秒 在连接成功之前和播放中途,如果超过设定时长无数据返回,则回调timeout事件
|
|
156
|
+
* @private
|
|
157
|
+
* @param {number} time 设置超时时长, 单位秒
|
|
158
|
+
* @returns {void}
|
|
159
|
+
* @example
|
|
160
|
+
* flv.setTimeout(3)
|
|
161
|
+
*/
|
|
162
|
+
private setTimeout;
|
|
163
|
+
/**
|
|
164
|
+
* @description 设置渲染的模式 (video 不支持)
|
|
165
|
+
* @private
|
|
166
|
+
* @param {0 | 1 | 2} type 0: 完全填充canvas区域; 1: 等比缩放, 最大边填充 ; 2: 等比缩放后,最小边填充,完全填充canvas区域,画面不被拉伸,没有黑边,但画面显示不全
|
|
167
|
+
* @returns {Promise}
|
|
168
|
+
* @example
|
|
169
|
+
* flv.setScaleMode(1)
|
|
170
|
+
*/
|
|
171
|
+
private setScaleMode;
|
|
172
|
+
/**
|
|
173
|
+
* @description 暂停
|
|
174
|
+
* @returns {Promise<unknown>}
|
|
175
|
+
* @example
|
|
176
|
+
* flv.pause()
|
|
177
|
+
*/
|
|
178
|
+
pause(): Promise<unknown>;
|
|
179
|
+
/**
|
|
180
|
+
* @description 关闭视频,不释放底层资源
|
|
181
|
+
* @private
|
|
182
|
+
* @returns {void}
|
|
183
|
+
* @example
|
|
184
|
+
* flv.close()
|
|
185
|
+
*/
|
|
186
|
+
private close;
|
|
187
|
+
/**
|
|
188
|
+
* @description 清理画布为黑色背景
|
|
189
|
+
* @private
|
|
190
|
+
* @returns {void}
|
|
191
|
+
* @example
|
|
192
|
+
* flv.clearView()
|
|
193
|
+
*/
|
|
194
|
+
private clearView;
|
|
195
|
+
/**
|
|
196
|
+
* @description 播放
|
|
197
|
+
* @param {(string | FlvOptions)=} options
|
|
198
|
+
* @returns {Promise}
|
|
199
|
+
* @example
|
|
200
|
+
* flv.play()
|
|
201
|
+
*/
|
|
202
|
+
play(options?: (string | FlvOptions) | undefined): Promise<any>;
|
|
203
|
+
/**
|
|
204
|
+
* @description 播放
|
|
205
|
+
* @private
|
|
206
|
+
* @param {string} url
|
|
207
|
+
* @param {object=} options
|
|
208
|
+
* @returns {Promise<unknown>}
|
|
209
|
+
*/
|
|
210
|
+
private _play;
|
|
211
|
+
/**
|
|
212
|
+
* @description 重新调整视图大小
|
|
213
|
+
* @param {number=} width 宽
|
|
214
|
+
* @param {number=} height 高
|
|
215
|
+
* @example
|
|
216
|
+
* flv.resize()
|
|
217
|
+
*/
|
|
218
|
+
resize(width?: number | undefined, height?: number | undefined): void;
|
|
219
|
+
/**
|
|
220
|
+
* @description 设置最大缓冲时长,单位秒,播放器会自动消除延迟。软解
|
|
221
|
+
* @private
|
|
222
|
+
* @param {number} time 大缓冲时长 s
|
|
223
|
+
* @example
|
|
224
|
+
* flv.setBufferTime(3)
|
|
225
|
+
*/
|
|
226
|
+
private setBufferTime;
|
|
227
|
+
/**
|
|
228
|
+
* @description 设置旋转角度,支持,0(默认), 90, 180, 270 四个值。
|
|
229
|
+
* @returns {Promise}
|
|
230
|
+
* @param {number} deg
|
|
231
|
+
* @example
|
|
232
|
+
* flv.setRotate(90) // 旋转90度
|
|
233
|
+
*/
|
|
234
|
+
setRotate(deg: number): Promise<any>;
|
|
235
|
+
/**
|
|
236
|
+
* @description 返回是否加载完毕
|
|
237
|
+
* @private
|
|
238
|
+
* @returns {boolean}
|
|
239
|
+
*/
|
|
240
|
+
private hasLoaded;
|
|
241
|
+
/**
|
|
242
|
+
* @description 开启屏幕常亮,在手机浏览器上
|
|
243
|
+
* @returns {void}
|
|
244
|
+
* @example
|
|
245
|
+
* flv.setKeepScreenOn()
|
|
246
|
+
*/
|
|
247
|
+
setKeepScreenOn(): void;
|
|
248
|
+
/**
|
|
249
|
+
* @description 全屏(取消全屏)播放视频
|
|
250
|
+
* @private
|
|
251
|
+
* @param {Boolean} flag
|
|
252
|
+
*/
|
|
253
|
+
private _setFullscreen;
|
|
254
|
+
/**
|
|
255
|
+
* @description 全屏播放视频
|
|
256
|
+
* @returns {Promise}
|
|
257
|
+
* @example
|
|
258
|
+
* flv.fullScreen() // 全屏
|
|
259
|
+
*
|
|
260
|
+
*/
|
|
261
|
+
fullScreen(): Promise<any>;
|
|
262
|
+
/**
|
|
263
|
+
* @description 退出全屏播放视频
|
|
264
|
+
* @returns {Promise}
|
|
265
|
+
* @example
|
|
266
|
+
* flv.cancelFullScreen() // 退出全屏
|
|
267
|
+
*/
|
|
268
|
+
cancelFullScreen(): Promise<any>;
|
|
269
|
+
/**
|
|
270
|
+
* @description 退出全屏播放视频
|
|
271
|
+
* @private
|
|
272
|
+
* @returns {Promise}
|
|
273
|
+
*/
|
|
274
|
+
private _exitFullscreen;
|
|
275
|
+
/**
|
|
276
|
+
* @description 获取播放器的状态
|
|
277
|
+
* @returns {PlayerState} 播放器的状态
|
|
278
|
+
* @example
|
|
279
|
+
* flv.getState()
|
|
280
|
+
*/
|
|
281
|
+
getState(): PlayerState;
|
|
282
|
+
/**
|
|
283
|
+
* @description 获取设置
|
|
284
|
+
* @returns {object}
|
|
285
|
+
*/
|
|
286
|
+
getOptions(): object;
|
|
287
|
+
}
|
|
288
|
+
import BasePlayer from '@ezuikit/player-base';
|
|
289
|
+
import Events from './utils/events';
|
|
290
|
+
import Player from './player';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export default class BasePlayer extends Emitter {
|
|
2
|
+
constructor(container: any, options: any, Video: any);
|
|
3
|
+
$container: any;
|
|
4
|
+
_opt: any;
|
|
5
|
+
debug: Debug;
|
|
6
|
+
_loading: boolean;
|
|
7
|
+
_playing: boolean;
|
|
8
|
+
_hasLoaded: boolean;
|
|
9
|
+
_checkHeartTimeout: any;
|
|
10
|
+
_checkLoadingTimeout: any;
|
|
11
|
+
_checkStatsInterval: any;
|
|
12
|
+
_startBpsTime: any;
|
|
13
|
+
_isPlayingBeforePageHidden: boolean;
|
|
14
|
+
_stats: {
|
|
15
|
+
buf: number;
|
|
16
|
+
fps: number;
|
|
17
|
+
abps: number;
|
|
18
|
+
vbps: number;
|
|
19
|
+
ts: number;
|
|
20
|
+
};
|
|
21
|
+
_times: {
|
|
22
|
+
playInitStart: string;
|
|
23
|
+
playStart: string;
|
|
24
|
+
streamStart: string;
|
|
25
|
+
streamResponse: string;
|
|
26
|
+
demuxStart: string;
|
|
27
|
+
decodeStart: string;
|
|
28
|
+
videoStart: string;
|
|
29
|
+
playTimestamp: string;
|
|
30
|
+
streamTimestamp: string;
|
|
31
|
+
streamResponseTimestamp: string;
|
|
32
|
+
demuxTimestamp: string;
|
|
33
|
+
decodeTimestamp: string;
|
|
34
|
+
videoTimestamp: string;
|
|
35
|
+
allTimestamp: string;
|
|
36
|
+
};
|
|
37
|
+
_videoTimestamp: number;
|
|
38
|
+
_audioTimestamp: number;
|
|
39
|
+
events: Events;
|
|
40
|
+
video: any;
|
|
41
|
+
control: Control;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param options
|
|
45
|
+
*/
|
|
46
|
+
updateOption(options: any): void;
|
|
47
|
+
}
|
|
48
|
+
import Emitter from '../utils/emitter';
|
|
49
|
+
import Debug from '../utils/debug';
|
|
50
|
+
import Events from '../utils/events';
|
|
51
|
+
import Control from '../control';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default class CommonLoader extends Emitter {
|
|
2
|
+
init: boolean;
|
|
3
|
+
resetInit(): void;
|
|
4
|
+
videoInfo: {
|
|
5
|
+
width: string;
|
|
6
|
+
height: string;
|
|
7
|
+
encType: string;
|
|
8
|
+
encTypeCode: string;
|
|
9
|
+
};
|
|
10
|
+
destroy(): void;
|
|
11
|
+
updateVideoInfo(data: any): void;
|
|
12
|
+
play(): void;
|
|
13
|
+
pause(): void;
|
|
14
|
+
clearView(): void;
|
|
15
|
+
}
|
|
16
|
+
import Emitter from '../utils/emitter';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type PlayerInterface, type RequiredFlvOptions } from '../interface';
|
|
2
|
+
import Events from '../../utils/events';
|
|
3
|
+
import Video from './videoLoader';
|
|
4
|
+
import type Control from '../../control';
|
|
5
|
+
import BasePlayer from '../base-player';
|
|
6
|
+
/**
|
|
7
|
+
* @class
|
|
8
|
+
*
|
|
9
|
+
* @interface {PlayerInterface}
|
|
10
|
+
*/
|
|
11
|
+
export default class HardPlayer extends BasePlayer implements PlayerInterface {
|
|
12
|
+
player: any;
|
|
13
|
+
video: Video;
|
|
14
|
+
events: Events;
|
|
15
|
+
_playing: any;
|
|
16
|
+
_lastVolume: any;
|
|
17
|
+
_loading: any;
|
|
18
|
+
_audioTimestamp: any;
|
|
19
|
+
_videoTimestamp: any;
|
|
20
|
+
_times: any;
|
|
21
|
+
$container: HTMLElement;
|
|
22
|
+
_opt: RequiredFlvOptions;
|
|
23
|
+
_hasLoaded: boolean;
|
|
24
|
+
_checkHeartTimeout: number;
|
|
25
|
+
_stats: any;
|
|
26
|
+
_checkLoadingTimeout: number;
|
|
27
|
+
control: Control;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
_pause: boolean;
|
|
31
|
+
_decodedFrames: number;
|
|
32
|
+
constructor(container: HTMLElement, options: RequiredFlvOptions);
|
|
33
|
+
close(): Promise<unknown>;
|
|
34
|
+
_createPlayer(options: RequiredFlvOptions): void;
|
|
35
|
+
_flvEvents(): void;
|
|
36
|
+
getOption(): RequiredFlvOptions;
|
|
37
|
+
emitError(errorType: string, message?: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* @description 销毁实例
|
|
40
|
+
*/
|
|
41
|
+
destroy(): void;
|
|
42
|
+
resetStats(): void;
|
|
43
|
+
set fullscreen(value: any);
|
|
44
|
+
get fullscreen(): any;
|
|
45
|
+
set webFullscreen(value: boolean);
|
|
46
|
+
get webFullscreen(): boolean;
|
|
47
|
+
set loaded(value: boolean);
|
|
48
|
+
get loaded(): boolean;
|
|
49
|
+
set playing(value: any);
|
|
50
|
+
get playing(): any;
|
|
51
|
+
get volume(): number;
|
|
52
|
+
set volume(value: number);
|
|
53
|
+
get lastVolume(): any;
|
|
54
|
+
set loading(value: any);
|
|
55
|
+
get loading(): any;
|
|
56
|
+
set audioTimestamp(value: any);
|
|
57
|
+
get audioTimestamp(): any;
|
|
58
|
+
set videoTimestamp(value: any);
|
|
59
|
+
get videoTimestamp(): any;
|
|
60
|
+
get isDebug(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 心跳检查
|
|
63
|
+
*/
|
|
64
|
+
checkHeart(): void;
|
|
65
|
+
clearCheckHeartTimeout(): void;
|
|
66
|
+
/**
|
|
67
|
+
* @description 心跳检查,如果渲染间隔暂停了多少时间之后,就会抛出异常
|
|
68
|
+
*/
|
|
69
|
+
checkHeartTimeout(): void;
|
|
70
|
+
/**
|
|
71
|
+
* @description 检查等待时间 (loading 等待时间)
|
|
72
|
+
*/
|
|
73
|
+
checkLoadingTimeout(): void;
|
|
74
|
+
handleRender(): void;
|
|
75
|
+
clearCheckLoadingTimeout(): void;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param options
|
|
79
|
+
*/
|
|
80
|
+
updateOption(options: Partial<RequiredFlvOptions>): void;
|
|
81
|
+
/**
|
|
82
|
+
* @description 播放
|
|
83
|
+
* @param url
|
|
84
|
+
* @param options
|
|
85
|
+
* @returns {Promise}
|
|
86
|
+
*/
|
|
87
|
+
play(): Promise<unknown>;
|
|
88
|
+
_play(): Promise<void>;
|
|
89
|
+
_close(): Promise<unknown>;
|
|
90
|
+
pause(): Promise<unknown>;
|
|
91
|
+
resumeAudioAfterPause(): void;
|
|
92
|
+
mute(flag: boolean): void;
|
|
93
|
+
resize(): void;
|
|
94
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import CommonLoader from '../commonLoader';
|
|
2
|
+
import { ScreenshotFormat } from '../interface';
|
|
3
|
+
import HardPlayer from '.';
|
|
4
|
+
export default class VideoLoader extends CommonLoader {
|
|
5
|
+
_delayPlay: boolean;
|
|
6
|
+
$canvasElement: HTMLCanvasElement;
|
|
7
|
+
canvasContext: CanvasRenderingContext2D | null;
|
|
8
|
+
trackGenerator: any;
|
|
9
|
+
vwriter: any;
|
|
10
|
+
$videoElement: HTMLVideoElement;
|
|
11
|
+
player: HardPlayer;
|
|
12
|
+
$posterElement: HTMLImageElement;
|
|
13
|
+
constructor(player: HardPlayer);
|
|
14
|
+
destroy(): void;
|
|
15
|
+
fixChromeVideoFlashBug(): void;
|
|
16
|
+
play(): void;
|
|
17
|
+
_getVideoReadyState(): number;
|
|
18
|
+
_play(): void;
|
|
19
|
+
pause(isNow?: boolean): void;
|
|
20
|
+
clearView(): void;
|
|
21
|
+
screenshot(filename: string, format?: keyof ScreenshotFormat, quality?: number, type?: string): string | File;
|
|
22
|
+
initCanvasViewSize(): void;
|
|
23
|
+
_poster(): void;
|
|
24
|
+
render(msg: any): void;
|
|
25
|
+
resize(): void;
|
|
26
|
+
_resizeElement($Element: HTMLVideoElement | HTMLImageElement): void;
|
|
27
|
+
isPlaying(): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import Debug from '../utils/debug';
|
|
2
|
+
export type TFlvOptions = {
|
|
3
|
+
container: string | HTMLElement;
|
|
4
|
+
videoBuffer: number;
|
|
5
|
+
decoder?: string;
|
|
6
|
+
forceNoOffscreen?: boolean;
|
|
7
|
+
hasAudio?: boolean;
|
|
8
|
+
scaleMode: 0 | 1 | 2;
|
|
9
|
+
debug: boolean;
|
|
10
|
+
timeout: number;
|
|
11
|
+
heartTimeout: number;
|
|
12
|
+
heartTimeoutReplayTimes: number;
|
|
13
|
+
loadingTimeout: number;
|
|
14
|
+
loadingTimeoutReplay: boolean;
|
|
15
|
+
keepScreenOn: boolean;
|
|
16
|
+
isNotMute: boolean;
|
|
17
|
+
useMSE: boolean;
|
|
18
|
+
autoWasm: boolean;
|
|
19
|
+
wasmDecodeErrorReplay: boolean;
|
|
20
|
+
useWebFullScreen: boolean;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
export type RequiredFlvOptions = Required<TFlvOptions> & {
|
|
25
|
+
url: string;
|
|
26
|
+
rotate?: 0 | 90 | 180 | 270;
|
|
27
|
+
hasControl: any;
|
|
28
|
+
openWebglAlignment?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type TPlayerTimes = {
|
|
31
|
+
playInitStart: number;
|
|
32
|
+
playStart: number;
|
|
33
|
+
streamStart: number;
|
|
34
|
+
streamResponse: number;
|
|
35
|
+
demuxStart: number;
|
|
36
|
+
decodeStart: number;
|
|
37
|
+
videoStart: number;
|
|
38
|
+
playTimestamp: number;
|
|
39
|
+
streamTimestamp: number;
|
|
40
|
+
streamResponseTimestamp: number;
|
|
41
|
+
demuxTimestamp: number;
|
|
42
|
+
decodeTimestamp: number;
|
|
43
|
+
videoTimestamp: number;
|
|
44
|
+
allTimestamp: number;
|
|
45
|
+
};
|
|
46
|
+
export type TPlayerStats = {
|
|
47
|
+
buf: number;
|
|
48
|
+
fps: number;
|
|
49
|
+
abps: number;
|
|
50
|
+
vbps: number;
|
|
51
|
+
ts: number;
|
|
52
|
+
};
|
|
53
|
+
export interface VideoInterface {
|
|
54
|
+
player: any;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
initCanvasViewSize(): void;
|
|
57
|
+
render(msg: any): void;
|
|
58
|
+
screenshot(filename?: string, format?: string, quality?: number, type?: string): void;
|
|
59
|
+
clearView(): void;
|
|
60
|
+
resize(): void;
|
|
61
|
+
}
|
|
62
|
+
export interface PlayerInterface {
|
|
63
|
+
$container: any;
|
|
64
|
+
debug: Debug;
|
|
65
|
+
_opt: RequiredFlvOptions;
|
|
66
|
+
/**
|
|
67
|
+
* @description 播放
|
|
68
|
+
* @param url
|
|
69
|
+
* @param options
|
|
70
|
+
*/
|
|
71
|
+
play(options?: TFlvOptions): Promise<unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* @description 暂停
|
|
74
|
+
*/
|
|
75
|
+
pause(flag?: boolean): Promise<unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* @description 静音
|
|
78
|
+
* @param flag
|
|
79
|
+
*/
|
|
80
|
+
mute(flag?: boolean): void;
|
|
81
|
+
/**
|
|
82
|
+
* @description resize
|
|
83
|
+
*/
|
|
84
|
+
resize(): void;
|
|
85
|
+
/**
|
|
86
|
+
* @description 关闭
|
|
87
|
+
*/
|
|
88
|
+
close(): Promise<unknown>;
|
|
89
|
+
/**
|
|
90
|
+
* @description 销毁实例
|
|
91
|
+
*/
|
|
92
|
+
destroy(): void;
|
|
93
|
+
}
|
|
94
|
+
export type VideoInfo = {
|
|
95
|
+
width: string;
|
|
96
|
+
height: string;
|
|
97
|
+
encType: string;
|
|
98
|
+
encTypeCode?: 7 | 12 | '';
|
|
99
|
+
};
|
|
100
|
+
export type ScreenshotFormat = Record<'png' | 'jpeg' | 'webp', string>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default class CanvasVideoLoader extends CommonLoader {
|
|
2
|
+
constructor(player: any);
|
|
3
|
+
player: any;
|
|
4
|
+
$videoElement: HTMLCanvasElement;
|
|
5
|
+
context2D: CanvasRenderingContext2D;
|
|
6
|
+
contextGl: any;
|
|
7
|
+
contextGlRender: (w: any, h: any, y: any, u: any, v: any) => void;
|
|
8
|
+
contextGlDestroy: () => void;
|
|
9
|
+
bitmaprenderer: ImageBitmapRenderingContext;
|
|
10
|
+
renderType: string;
|
|
11
|
+
videoInfo: {
|
|
12
|
+
width: string;
|
|
13
|
+
height: string;
|
|
14
|
+
encType: string;
|
|
15
|
+
};
|
|
16
|
+
_contextmenuEvent: (e: any) => void;
|
|
17
|
+
_initContextGl(): void;
|
|
18
|
+
_initContext2D(): void;
|
|
19
|
+
_initCanvasRender(): void;
|
|
20
|
+
_supportOffscreen(): any;
|
|
21
|
+
_bindOffscreen(): void;
|
|
22
|
+
initCanvasViewSize(): void;
|
|
23
|
+
render(msg: any): void;
|
|
24
|
+
screenshot(filename: any, format: any, quality: any, type: any): string | File;
|
|
25
|
+
resize(): void;
|
|
26
|
+
}
|
|
27
|
+
import CommonLoader from '../commonLoader';
|