ezuikit-flv 1.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/CHANGELOG.md +7 -0
- package/README.md +83 -0
- package/decoder.js +6 -0
- package/decoder.wasm +0 -0
- package/index.js +15 -0
- package/package.json +20 -0
- package/types/audio/audioContextLoader.d.ts +42 -0
- package/types/audio/index.d.ts +5 -0
- package/types/constant/index.d.ts +263 -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 +248 -0
- package/types/player/base-player.d.ts +46 -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 +95 -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 +98 -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 +26 -0
- package/types/player/soft-player/index.d.ts +96 -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 +143 -0
- package/types/utils/codec-support.d.ts +2 -0
- package/types/utils/debug.d.ts +6 -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 +22 -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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PlayerInterface } from '../interface';
|
|
2
|
+
import Debug from '../../utils/debug';
|
|
3
|
+
import Events from '../../utils/events';
|
|
4
|
+
import Video from './videoLoader';
|
|
5
|
+
import Control from '../../control';
|
|
6
|
+
import { RequiredFlvOptions } from '../interface';
|
|
7
|
+
import BasePlayer from '../base-player';
|
|
8
|
+
/**
|
|
9
|
+
* @class
|
|
10
|
+
*
|
|
11
|
+
* @interface {PlayerInterface}
|
|
12
|
+
*/
|
|
13
|
+
export default class HardPlayer extends BasePlayer implements PlayerInterface {
|
|
14
|
+
player: any;
|
|
15
|
+
video: Video;
|
|
16
|
+
events: Events;
|
|
17
|
+
_playing: any;
|
|
18
|
+
_lastVolume: any;
|
|
19
|
+
_loading: any;
|
|
20
|
+
_audioTimestamp: any;
|
|
21
|
+
_videoTimestamp: any;
|
|
22
|
+
_times: any;
|
|
23
|
+
$container: HTMLElement;
|
|
24
|
+
_opt: RequiredFlvOptions;
|
|
25
|
+
debug: Debug;
|
|
26
|
+
_hasLoaded: boolean;
|
|
27
|
+
_checkHeartTimeout: number;
|
|
28
|
+
_stats: any;
|
|
29
|
+
_checkLoadingTimeout: number;
|
|
30
|
+
control: Control;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
constructor(container: HTMLElement, options: RequiredFlvOptions);
|
|
34
|
+
close(): Promise<unknown>;
|
|
35
|
+
_createPlayer(options: RequiredFlvOptions): void;
|
|
36
|
+
_flvEvents(): void;
|
|
37
|
+
getOption(): RequiredFlvOptions;
|
|
38
|
+
emitError(errorType: string, message?: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* @description 销毁实例
|
|
41
|
+
*/
|
|
42
|
+
destroy(): void;
|
|
43
|
+
resetStats(): void;
|
|
44
|
+
set fullscreen(value: any);
|
|
45
|
+
get fullscreen(): any;
|
|
46
|
+
set webFullscreen(value: boolean);
|
|
47
|
+
get webFullscreen(): boolean;
|
|
48
|
+
set loaded(value: boolean);
|
|
49
|
+
get loaded(): boolean;
|
|
50
|
+
set playing(value: any);
|
|
51
|
+
get playing(): any;
|
|
52
|
+
get volume(): number;
|
|
53
|
+
set volume(value: number);
|
|
54
|
+
get lastVolume(): any;
|
|
55
|
+
set loading(value: any);
|
|
56
|
+
get loading(): any;
|
|
57
|
+
set audioTimestamp(value: any);
|
|
58
|
+
get audioTimestamp(): any;
|
|
59
|
+
set videoTimestamp(value: any);
|
|
60
|
+
get videoTimestamp(): any;
|
|
61
|
+
get isDebug(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 心跳检查
|
|
64
|
+
*/
|
|
65
|
+
checkHeart(): void;
|
|
66
|
+
clearCheckHeartTimeout(): void;
|
|
67
|
+
/**
|
|
68
|
+
* @description 心跳检查,如果渲染间隔暂停了多少时间之后,就会抛出异常
|
|
69
|
+
*/
|
|
70
|
+
checkHeartTimeout(): void;
|
|
71
|
+
/**
|
|
72
|
+
* @description 检查等待时间 (loading 等待时间)
|
|
73
|
+
*/
|
|
74
|
+
checkLoadingTimeout(): void;
|
|
75
|
+
handleRender(): void;
|
|
76
|
+
clearCheckLoadingTimeout(): void;
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param options
|
|
80
|
+
*/
|
|
81
|
+
updateOption(options: Partial<RequiredFlvOptions>): void;
|
|
82
|
+
/**
|
|
83
|
+
* @description 播放
|
|
84
|
+
* @param url
|
|
85
|
+
* @param options
|
|
86
|
+
* @returns {Promise}
|
|
87
|
+
*/
|
|
88
|
+
play(): Promise<unknown>;
|
|
89
|
+
_play(): Promise<void>;
|
|
90
|
+
_close(): Promise<unknown>;
|
|
91
|
+
pause(): Promise<unknown>;
|
|
92
|
+
resumeAudioAfterPause(): void;
|
|
93
|
+
mute(flag: boolean): void;
|
|
94
|
+
resize(): void;
|
|
95
|
+
}
|
|
@@ -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,98 @@
|
|
|
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
|
+
};
|
|
22
|
+
export type RequiredFlvOptions = Required<TFlvOptions> & {
|
|
23
|
+
url: string;
|
|
24
|
+
rotate?: 0 | 90 | 180 | 270;
|
|
25
|
+
hasControl: any;
|
|
26
|
+
openWebglAlignment?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type TPlayerTimes = {
|
|
29
|
+
playInitStart: number;
|
|
30
|
+
playStart: number;
|
|
31
|
+
streamStart: number;
|
|
32
|
+
streamResponse: number;
|
|
33
|
+
demuxStart: number;
|
|
34
|
+
decodeStart: number;
|
|
35
|
+
videoStart: number;
|
|
36
|
+
playTimestamp: number;
|
|
37
|
+
streamTimestamp: number;
|
|
38
|
+
streamResponseTimestamp: number;
|
|
39
|
+
demuxTimestamp: number;
|
|
40
|
+
decodeTimestamp: number;
|
|
41
|
+
videoTimestamp: number;
|
|
42
|
+
allTimestamp: number;
|
|
43
|
+
};
|
|
44
|
+
export type TPlayerStats = {
|
|
45
|
+
buf: number;
|
|
46
|
+
fps: number;
|
|
47
|
+
abps: number;
|
|
48
|
+
vbps: number;
|
|
49
|
+
ts: number;
|
|
50
|
+
};
|
|
51
|
+
export interface VideoInterface {
|
|
52
|
+
player: any;
|
|
53
|
+
destroy(): void;
|
|
54
|
+
initCanvasViewSize(): void;
|
|
55
|
+
render(msg: any): void;
|
|
56
|
+
screenshot(filename?: string, format?: string, quality?: number, type?: string): void;
|
|
57
|
+
clearView(): void;
|
|
58
|
+
resize(): void;
|
|
59
|
+
}
|
|
60
|
+
export interface PlayerInterface {
|
|
61
|
+
$container: any;
|
|
62
|
+
debug: Debug;
|
|
63
|
+
_opt: RequiredFlvOptions;
|
|
64
|
+
/**
|
|
65
|
+
* @description 播放
|
|
66
|
+
* @param url
|
|
67
|
+
* @param options
|
|
68
|
+
*/
|
|
69
|
+
play(options?: TFlvOptions): Promise<unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* @description 暂停
|
|
72
|
+
*/
|
|
73
|
+
pause(flag?: boolean): Promise<unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* @description 静音
|
|
76
|
+
* @param flag
|
|
77
|
+
*/
|
|
78
|
+
mute(flag?: boolean): void;
|
|
79
|
+
/**
|
|
80
|
+
* @description resize
|
|
81
|
+
*/
|
|
82
|
+
resize(): void;
|
|
83
|
+
/**
|
|
84
|
+
* @description 关闭
|
|
85
|
+
*/
|
|
86
|
+
close(): Promise<unknown>;
|
|
87
|
+
/**
|
|
88
|
+
* @description 销毁实例
|
|
89
|
+
*/
|
|
90
|
+
destroy(): void;
|
|
91
|
+
}
|
|
92
|
+
export type VideoInfo = {
|
|
93
|
+
width: string;
|
|
94
|
+
height: string;
|
|
95
|
+
encType: string;
|
|
96
|
+
encTypeCode?: 7 | 12 | '';
|
|
97
|
+
};
|
|
98
|
+
export type ScreenshotFormat = Record<'png' | 'jpeg' | 'webp', string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
_initContextGl(): void;
|
|
17
|
+
_initContext2D(): void;
|
|
18
|
+
_initCanvasRender(): void;
|
|
19
|
+
_supportOffscreen(): any;
|
|
20
|
+
_bindOffscreen(): void;
|
|
21
|
+
initCanvasViewSize(): void;
|
|
22
|
+
render(msg: any): void;
|
|
23
|
+
screenshot(filename: any, format: any, quality: any, type: any): string | File;
|
|
24
|
+
resize(): void;
|
|
25
|
+
}
|
|
26
|
+
import CommonLoader from '../commonLoader';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export default class SoftPlayer extends BasePlayer {
|
|
2
|
+
constructor(container: any, options: any);
|
|
3
|
+
audio: Audio;
|
|
4
|
+
decoderWorker: DecoderWorker;
|
|
5
|
+
stream: Stream;
|
|
6
|
+
demux: Demux;
|
|
7
|
+
_lastVolume: any;
|
|
8
|
+
keepScreenOn: NoSleep;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
set fullscreen(arg: any);
|
|
11
|
+
get fullscreen(): any;
|
|
12
|
+
set webFullscreen(arg: any);
|
|
13
|
+
get webFullscreen(): any;
|
|
14
|
+
set loaded(arg: boolean);
|
|
15
|
+
get loaded(): boolean;
|
|
16
|
+
set playing(arg: boolean);
|
|
17
|
+
get playing(): boolean;
|
|
18
|
+
set loading(arg: boolean);
|
|
19
|
+
get loading(): boolean;
|
|
20
|
+
set volume(arg: any);
|
|
21
|
+
get volume(): any;
|
|
22
|
+
get lastVolume(): any;
|
|
23
|
+
set audioTimestamp(arg: number);
|
|
24
|
+
get audioTimestamp(): number;
|
|
25
|
+
set videoTimestamp(arg: number);
|
|
26
|
+
get videoTimestamp(): number;
|
|
27
|
+
get isDebug(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param options
|
|
31
|
+
*/
|
|
32
|
+
updateOption(options: any): void;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @returns {Promise<unknown>}
|
|
36
|
+
*/
|
|
37
|
+
init(): Promise<unknown>;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param url
|
|
41
|
+
* @returns {Promise<unknown>}
|
|
42
|
+
*/
|
|
43
|
+
play(options: any): Promise<unknown>;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
close(): Promise<any>;
|
|
48
|
+
resumeAudioAfterPause(): void;
|
|
49
|
+
_close(): Promise<any>;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param flag {boolean} 是否清除画面
|
|
53
|
+
* @returns {Promise<unknown>}
|
|
54
|
+
*/
|
|
55
|
+
pause(flag?: boolean): Promise<unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* @description 静音
|
|
58
|
+
* @param flag
|
|
59
|
+
*/
|
|
60
|
+
mute(flag: any): void;
|
|
61
|
+
/**
|
|
62
|
+
* @description 重置尺寸
|
|
63
|
+
*/
|
|
64
|
+
resize(): void;
|
|
65
|
+
_onlyMseOrWcsVideo(): any;
|
|
66
|
+
/**
|
|
67
|
+
* 心跳检查
|
|
68
|
+
*/
|
|
69
|
+
checkHeart(): void;
|
|
70
|
+
/**
|
|
71
|
+
* @description 心跳检查,如果渲染间隔暂停了多少时间之后,就会抛出异常
|
|
72
|
+
*/
|
|
73
|
+
checkHeartTimeout(): void;
|
|
74
|
+
checkStatsInterval(): void;
|
|
75
|
+
clearCheckHeartTimeout(): void;
|
|
76
|
+
/**
|
|
77
|
+
* @description 检查等待时间 (loading 等待时间)
|
|
78
|
+
*/
|
|
79
|
+
checkLoadingTimeout(): void;
|
|
80
|
+
clearCheckLoadingTimeout(): void;
|
|
81
|
+
clearStatsInterval(): void;
|
|
82
|
+
handleRender(): void;
|
|
83
|
+
updateStats(options: any): void;
|
|
84
|
+
resetStats(): void;
|
|
85
|
+
enableWakeLock(): void;
|
|
86
|
+
releaseWakeLock(): void;
|
|
87
|
+
handlePlayToRenderTimes(): void;
|
|
88
|
+
getOption(): any;
|
|
89
|
+
emitError(errorType: any, message?: string): void;
|
|
90
|
+
}
|
|
91
|
+
import BasePlayer from '../base-player';
|
|
92
|
+
import Audio from '../../audio';
|
|
93
|
+
import DecoderWorker from '../../worker/index';
|
|
94
|
+
import Stream from '../../stream';
|
|
95
|
+
import Demux from '../../demux';
|
|
96
|
+
import NoSleep from '../../utils/noSleep';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default class FetchLoader extends Emitter {
|
|
2
|
+
constructor(player: any);
|
|
3
|
+
player: any;
|
|
4
|
+
playing: boolean;
|
|
5
|
+
abortController: AbortController;
|
|
6
|
+
streamRate: (size: any) => void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param url
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
fetchStream(url: any, options?: {}): void;
|
|
14
|
+
abort(): void;
|
|
15
|
+
}
|
|
16
|
+
import Emitter from '../utils/emitter';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default class WebsocketLoader extends Emitter {
|
|
2
|
+
constructor(player: any);
|
|
3
|
+
player: any;
|
|
4
|
+
socket: WebSocket;
|
|
5
|
+
socketStatus: string;
|
|
6
|
+
wsUrl: any;
|
|
7
|
+
streamRate: (size: any) => void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
_createWebSocket(): void;
|
|
10
|
+
_handleMessage(message: any): void;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param url
|
|
14
|
+
* @param options
|
|
15
|
+
*/
|
|
16
|
+
fetchStream(url: any, options: any): void;
|
|
17
|
+
}
|
|
18
|
+
import Emitter from '../utils/emitter';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @description Flv 配置项
|
|
4
|
+
* @typedef FlvOptions
|
|
5
|
+
*
|
|
6
|
+
* @property {string | HTMLElement} container 渲染容器
|
|
7
|
+
* @property {number=} videoBuffer 设置最大缓冲时长,单位秒,播放器会自动消除延迟。
|
|
8
|
+
* @property {string=} decoder 解码库worker地址 默认 `decoder.js`, wasm 文件要和decoder在同一个文件夹中
|
|
9
|
+
* @property {boolean=} forceNoOffscreen 是否不使用离屏模式(提升渲染能力)
|
|
10
|
+
* @property {boolean=} hasAudio 是否有音频,如果设置false,则不对音频数据解码,提升性能。
|
|
11
|
+
* @property {(0 | 1 | 2)=} scaleMode 设置渲染模式, 默认 1, 取值 0 | 1 | 2。
|
|
12
|
+
* @property {boolean=} debug 是否开启控制台调试打印。默认 false
|
|
13
|
+
* @property {number=} timeout 设置超时时长, 单位秒, 在连接成功之前(loading)和播放中途(heart),如果超过设定时长无数据返回,则回调timeout事件。默认 10
|
|
14
|
+
* @property {number=} heartTimeout 设置超时时长, 单位秒, 播放中途,如果超过设定时长无数据返回,则回调timeout事件。默认 5
|
|
15
|
+
* @property {number=} heartTimeoutReplayTimes `heartTimeoutReplay` 重试次数。默认 3
|
|
16
|
+
* @property {number=} loadingTimeout 设置超时时长, 单位秒。默认 10
|
|
17
|
+
* @property {boolean=} loadingTimeoutReplay 是否开启loading超时之后自动再播放, 默认 true
|
|
18
|
+
* @property {boolean=} keepScreenOn 开启屏幕常亮,在手机浏览器上, canvas标签渲染视频并不会像video标签那样保持屏幕常。默认 false
|
|
19
|
+
* @property {boolean=} isNotMute 是否开启声音,默认是关闭声音播放的。默认 false
|
|
20
|
+
* @property {boolean=} useMSE 是否开启MediaSource硬解码。视频编码只支持H.264视频(Safari on iOS不支持)。默认 false
|
|
21
|
+
* @property {boolean=} autoWasm 在使用MSE或者Webcodecs 播放H265的时候,是否自动降级到wasm模式。默认 true
|
|
22
|
+
* @property {boolean=} wasmDecodeErrorReplay 是否开启解码失败重新播放。默认 true
|
|
23
|
+
* @property {boolean=} useWebFullScreen 是否使用web全屏(旋转90度)(只会在移动端生效)。默认 false
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @description 播放器的状态
|
|
29
|
+
* @typedef PlayerState
|
|
30
|
+
*
|
|
31
|
+
* @property {boolean} playing 是否正在播放
|
|
32
|
+
* @property {boolean} mute 是否静音
|
|
33
|
+
* @property {boolean} fullscreen 是否全屏
|
|
34
|
+
* @property {boolean} webFullscreen 是否web全屏
|
|
35
|
+
* @property {boolean} loaded 是否加载完成
|
|
36
|
+
* @property {string} volume 音量
|
|
37
|
+
* @property {boolean} isDebug 是否打印日志
|
|
38
|
+
*/
|
|
39
|
+
export const Types: {};
|
|
40
|
+
export type FlvOptions = {
|
|
41
|
+
/**
|
|
42
|
+
* 渲染容器
|
|
43
|
+
*/
|
|
44
|
+
container: string | HTMLElement;
|
|
45
|
+
/**
|
|
46
|
+
* 设置最大缓冲时长,单位秒,播放器会自动消除延迟。
|
|
47
|
+
*/
|
|
48
|
+
videoBuffer?: number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* 解码库worker地址 默认 `decoder.js`, wasm 文件要和decoder在同一个文件夹中
|
|
51
|
+
*/
|
|
52
|
+
decoder?: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* 是否不使用离屏模式(提升渲染能力)
|
|
55
|
+
*/
|
|
56
|
+
forceNoOffscreen?: boolean | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* 是否有音频,如果设置false,则不对音频数据解码,提升性能。
|
|
59
|
+
*/
|
|
60
|
+
hasAudio?: boolean | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* 设置渲染模式, 默认 1, 取值 0 | 1 | 2。
|
|
63
|
+
*/
|
|
64
|
+
scaleMode?: (0 | 1 | 2) | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* 是否开启控制台调试打印。默认 false
|
|
67
|
+
*/
|
|
68
|
+
debug?: boolean | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* 设置超时时长, 单位秒, 在连接成功之前(loading)和播放中途(heart),如果超过设定时长无数据返回,则回调timeout事件。默认 10
|
|
71
|
+
*/
|
|
72
|
+
timeout?: number | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* 设置超时时长, 单位秒, 播放中途,如果超过设定时长无数据返回,则回调timeout事件。默认 5
|
|
75
|
+
*/
|
|
76
|
+
heartTimeout?: number | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* `heartTimeoutReplay` 重试次数。默认 3
|
|
79
|
+
*/
|
|
80
|
+
heartTimeoutReplayTimes?: number | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* 设置超时时长, 单位秒。默认 10
|
|
83
|
+
*/
|
|
84
|
+
loadingTimeout?: number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* 是否开启loading超时之后自动再播放, 默认 true
|
|
87
|
+
*/
|
|
88
|
+
loadingTimeoutReplay?: boolean | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* 开启屏幕常亮,在手机浏览器上, canvas标签渲染视频并不会像video标签那样保持屏幕常。默认 false
|
|
91
|
+
*/
|
|
92
|
+
keepScreenOn?: boolean | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* 是否开启声音,默认是关闭声音播放的。默认 false
|
|
95
|
+
*/
|
|
96
|
+
isNotMute?: boolean | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* 是否开启MediaSource硬解码。视频编码只支持H.264视频(Safari on iOS不支持)。默认 false
|
|
99
|
+
*/
|
|
100
|
+
useMSE?: boolean | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* 在使用MSE或者Webcodecs 播放H265的时候,是否自动降级到wasm模式。默认 true
|
|
103
|
+
*/
|
|
104
|
+
autoWasm?: boolean | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* 是否开启解码失败重新播放。默认 true
|
|
107
|
+
*/
|
|
108
|
+
wasmDecodeErrorReplay?: boolean | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* 是否使用web全屏(旋转90度)(只会在移动端生效)。默认 false
|
|
111
|
+
*/
|
|
112
|
+
useWebFullScreen?: boolean | undefined;
|
|
113
|
+
};
|
|
114
|
+
export type PlayerState = {
|
|
115
|
+
/**
|
|
116
|
+
* 是否正在播放
|
|
117
|
+
*/
|
|
118
|
+
playing: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 是否静音
|
|
121
|
+
*/
|
|
122
|
+
mute: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* 是否全屏
|
|
125
|
+
*/
|
|
126
|
+
fullscreen: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* 是否web全屏
|
|
129
|
+
*/
|
|
130
|
+
webFullscreen: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* 是否加载完成
|
|
133
|
+
*/
|
|
134
|
+
loaded: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* 音量
|
|
137
|
+
*/
|
|
138
|
+
volume: string;
|
|
139
|
+
/**
|
|
140
|
+
* 是否打印日志
|
|
141
|
+
*/
|
|
142
|
+
isDebug: boolean;
|
|
143
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function noop(): void;
|
|
2
|
+
export function supportOffscreen($canvas: any): boolean;
|
|
3
|
+
export function supportOffscreenV2(): boolean;
|
|
4
|
+
export function createContextGL($canvas: any): any;
|
|
5
|
+
export function audioContextUnlock(context: any): void;
|
|
6
|
+
export function dataURLToFile(dataURL?: string): File;
|
|
7
|
+
export function downloadFile(file: any, fileName: any): void;
|
|
8
|
+
export function downloadImg(content: any, fileName: any): void;
|
|
9
|
+
export function checkFull(): boolean;
|
|
10
|
+
export function now(): number;
|
|
11
|
+
export function clamp(num: any, a: any, b: any): number;
|
|
12
|
+
export function setStyle(element: any, key: any, value: any): any;
|
|
13
|
+
export function getStyle(element: any, key: any, numberType?: boolean): string | number;
|
|
14
|
+
export function getNowTime(): number;
|
|
15
|
+
export function calculationRate(callback: any): (size: any) => void;
|
|
16
|
+
export function downloadRecord(blob: any, name: any, suffix: any): void;
|
|
17
|
+
export function isMobile(): boolean;
|
|
18
|
+
export function isAndroid(): boolean;
|
|
19
|
+
export function isIOS(): boolean;
|
|
20
|
+
export function parseTime(time: any, cFormat: any, ...args: any[]): any;
|
|
21
|
+
export function supportWCS(): boolean;
|
|
22
|
+
export function toNumber(value: any): any;
|
|
23
|
+
export function uuid16(): string;
|
|
24
|
+
export function throttle(callback: any, delay: any): (...args2: any[]) => void;
|
|
25
|
+
export function isDef(v: any): boolean;
|
|
26
|
+
export function formatVideoDecoderConfigure(avcC: any): {
|
|
27
|
+
codec: string;
|
|
28
|
+
description: any;
|
|
29
|
+
};
|
|
30
|
+
export function isFullScreen(): any;
|
|
31
|
+
export function bpsSize(value: any): string;
|
|
32
|
+
export function fpsStatus(fps: any): number;
|
|
33
|
+
export function createEmptyImageBitmap(width: any, height: any): Promise<ImageBitmap>;
|
|
34
|
+
export function supportMSE(): boolean;
|
|
35
|
+
export function supportMSEHevc(): boolean;
|
|
36
|
+
export function supportMediaStreamTrack(): boolean;
|
|
37
|
+
export function formatMp4VideoCodec(codec: any): string;
|
|
38
|
+
export function saveBlobToFile(fileName: any, blob: any): void;
|
|
39
|
+
export function isEmpty(value: any): boolean;
|
|
40
|
+
export function isBoolean(value: any): boolean;
|
|
41
|
+
export function isNotEmpty(value: any): boolean;
|
|
42
|
+
export function initPlayTimes(): {
|
|
43
|
+
playInitStart: string;
|
|
44
|
+
playStart: string;
|
|
45
|
+
streamStart: string;
|
|
46
|
+
streamResponse: string;
|
|
47
|
+
demuxStart: string;
|
|
48
|
+
decodeStart: string;
|
|
49
|
+
videoStart: string;
|
|
50
|
+
playTimestamp: string;
|
|
51
|
+
streamTimestamp: string;
|
|
52
|
+
streamResponseTimestamp: string;
|
|
53
|
+
demuxTimestamp: string;
|
|
54
|
+
decodeTimestamp: string;
|
|
55
|
+
videoTimestamp: string;
|
|
56
|
+
allTimestamp: string;
|
|
57
|
+
};
|
|
58
|
+
export function createWatermark(options: any): () => void;
|
|
59
|
+
export function formatTimeTips(time: any): string;
|
|
60
|
+
export function getTarget(e: any): any;
|
|
61
|
+
export function isWebglRenderSupport(width: any): boolean;
|
|
62
|
+
export function isGreenYUV(arrayBuffer: any): boolean;
|
|
63
|
+
export function getBrowser(): {
|
|
64
|
+
type: string;
|
|
65
|
+
version: number;
|
|
66
|
+
};
|
|
67
|
+
export function closeVideoFrame(videoFrame: any): void;
|
|
68
|
+
export function removeElement(element: any): boolean;
|
|
69
|
+
export const supportedWasm: boolean;
|
|
70
|
+
export const env: "__ENV__";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default Monitor;
|
|
2
|
+
declare class Monitor {
|
|
3
|
+
static vc: any;
|
|
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
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {'click' | 'error' | 'api' } type
|
|
13
|
+
* @param {ReportData} obj
|
|
14
|
+
*/
|
|
15
|
+
static report(type: 'click' | 'error' | 'api', obj: {
|
|
16
|
+
/**
|
|
17
|
+
* 事件名称 error | play | pause | openSound | closeSound | fullScreen | cancelFullScreen | setDebug | setKeepScreenOn | setVolume | setRotate | getState | getVersion
|
|
18
|
+
*/
|
|
19
|
+
event: string;
|
|
20
|
+
value: any;
|
|
21
|
+
}): void;
|
|
22
|
+
}
|