@havue/ws-video-manager 1.1.2 → 1.2.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/dist/types/src/loader/websocket-loader.d.ts +13 -10
- package/dist/types/src/manager/index.d.ts +54 -37
- package/dist/types/src/render/drawer.d.ts +7 -7
- package/dist/types/src/render/index.d.ts +35 -19
- package/dist/ws-video-manager.mjs +67 -54
- package/dist/ws-video-manager.umd.js +67 -54
- package/package.json +2 -2
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
/** 心跳配置 */
|
|
1
|
+
/** 心跳配置 | Heartbeat configuration */
|
|
2
2
|
type HeartbeatConfigType = {
|
|
3
|
-
/** 只发送一次 */
|
|
3
|
+
/** 只发送一次 | Only send it once */
|
|
4
4
|
once: boolean;
|
|
5
|
-
/** 心跳消息 */
|
|
5
|
+
/** 心跳消息 | Heartbeat message */
|
|
6
6
|
message: string;
|
|
7
|
-
/**
|
|
7
|
+
/** 心跳间隔 | Interval of heartbeat */
|
|
8
8
|
interval?: number;
|
|
9
9
|
};
|
|
10
|
-
/** 重连配置 */
|
|
10
|
+
/** 重连配置 | Reconnect configuration */
|
|
11
11
|
type InterruptConfigType = {
|
|
12
|
-
/** 是否重连 */
|
|
12
|
+
/** 是否重连 | Reconnect or not */
|
|
13
13
|
reconnect: boolean;
|
|
14
|
-
/** 最大重连次数 */
|
|
14
|
+
/** 最大重连次数 | Maximum number of reconnections */
|
|
15
15
|
maxReconnectTimes: number;
|
|
16
|
-
/** 每次重连延时 */
|
|
16
|
+
/** 每次重连延时 | Delay per reconnection */
|
|
17
17
|
delay: number;
|
|
18
18
|
};
|
|
19
19
|
export type WebSocketOptionsType = {
|
|
20
|
-
/** WebSocket
|
|
20
|
+
/** WebSocket subprotocol: WebSocket(url: string, protocols: string | string[]) */
|
|
21
21
|
protocols?: string | string[];
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* WebSocket 连接接收的二进制数据类型
|
|
24
|
+
* the type of binary data being received over the WebSocket connection
|
|
25
|
+
*/
|
|
23
26
|
binaryType?: WebSocket['binaryType'];
|
|
24
27
|
heartbeat?: HeartbeatConfigType;
|
|
25
28
|
interrupt?: InterruptConfigType;
|
|
@@ -3,21 +3,31 @@ import type { RenderConstructorOptionType, VideoInfo } from '../render';
|
|
|
3
3
|
import { EventBus } from '@havue/shared';
|
|
4
4
|
import { RenderEventsEnum, AudioState, VideoState } from '../render';
|
|
5
5
|
export type WsVideoManaCstorOptionType = {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* websocket流连接数量限制, 移动端默认10个,pc端默认32个
|
|
8
|
+
* Limit the number of websocket streaming connections to 10 by default for mobile and 32 by default for pc
|
|
9
|
+
*/
|
|
7
10
|
connectLimit?: number;
|
|
8
|
-
/** WebSocketLoader
|
|
11
|
+
/** WebSocketLoader configuration */
|
|
9
12
|
wsOptions?: WebSocketOptionsType;
|
|
10
13
|
/**
|
|
11
14
|
* websocket重连时,重新解析视频编码方式,
|
|
12
15
|
* 默认 true
|
|
16
|
+
*
|
|
17
|
+
* When the websocket reconnects, the video encoding is reparsed.
|
|
18
|
+
* The default is true
|
|
13
19
|
*/
|
|
14
20
|
reparseMimeOnReconnect?: boolean;
|
|
15
21
|
/** Render 实例配置 */
|
|
16
22
|
renderOptions?: Partial<RenderConstructorOptionType>;
|
|
17
23
|
/**
|
|
18
|
-
* 是否使用WebGL,
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* 是否使用WebGL,默认 false,
|
|
25
|
+
* WebGL在不同游览器,以及受限于显存,不能同时创建过多WebGL上下文,一般8-16个
|
|
26
|
+
*
|
|
27
|
+
* Whether to use WebGL, false by default,
|
|
28
|
+
* WebGL can not be created too many WebGL contexts at the same time in different browsers,
|
|
29
|
+
* and due to the limitations of video memory, usually 8-16 WebGL contexts
|
|
30
|
+
*/
|
|
21
31
|
useWebgl?: boolean;
|
|
22
32
|
};
|
|
23
33
|
export declare enum EventEnums {
|
|
@@ -35,7 +45,7 @@ type Events = {
|
|
|
35
45
|
};
|
|
36
46
|
export declare const WsVideoManagerEventEnums: typeof EventEnums & typeof RenderEventsEnum;
|
|
37
47
|
export declare class WsVideoManager extends EventBus<Events> {
|
|
38
|
-
/** socket
|
|
48
|
+
/** socket相关信息map | map of socket information */
|
|
39
49
|
private _wsInfoMap;
|
|
40
50
|
private _option;
|
|
41
51
|
private _reqAnimationID;
|
|
@@ -44,100 +54,107 @@ export declare class WsVideoManager extends EventBus<Events> {
|
|
|
44
54
|
get connectLimit(): number;
|
|
45
55
|
private _setAnimate;
|
|
46
56
|
/**
|
|
47
|
-
* 添加socket
|
|
48
|
-
* @param url socket
|
|
57
|
+
* 添加socket连接 | Adding a socket connection
|
|
58
|
+
* @param url socket url
|
|
49
59
|
* @returns
|
|
50
60
|
*/
|
|
51
61
|
private _addSocket;
|
|
52
62
|
/**
|
|
53
|
-
* 绑定render事件
|
|
54
|
-
* @param url 连接地址
|
|
55
|
-
* @param render Render
|
|
63
|
+
* 绑定render事件 | Binding the render event
|
|
64
|
+
* @param url 连接地址 | websocket url
|
|
65
|
+
* @param render Render instance
|
|
56
66
|
*/
|
|
57
67
|
private _bindRenderEvent;
|
|
58
68
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param url socket
|
|
69
|
+
* Destroying the socket connect
|
|
70
|
+
* @param url socket url
|
|
61
71
|
*/
|
|
62
72
|
private _removeSocket;
|
|
63
73
|
/**
|
|
64
|
-
* 绑定socket事件
|
|
65
|
-
* @param url
|
|
66
|
-
* @param socket WebSocketLoader
|
|
74
|
+
* 绑定socket事件 | Binding socket events
|
|
75
|
+
* @param url websocket url
|
|
76
|
+
* @param socket WebSocketLoader instance
|
|
67
77
|
*/
|
|
68
78
|
private _bindSocketEvent;
|
|
69
79
|
private _emitWsUrlListChange;
|
|
70
80
|
/**
|
|
71
|
-
* url对应的 socket实例是否已存在
|
|
72
|
-
* @param url
|
|
81
|
+
* url对应的 socket实例是否已存在 | Whether the socket instance for the url already exists
|
|
82
|
+
* @param url websocket url
|
|
73
83
|
* @returns boolean
|
|
74
84
|
*/
|
|
75
85
|
private _isSocketExist;
|
|
76
86
|
/**
|
|
77
87
|
* 添加url对应socket,以及需要绘制的canvas元素
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
88
|
+
* Add the socket for the url and the canvas element to draw
|
|
89
|
+
* @param canvas canvas
|
|
90
|
+
* @param url websocket url
|
|
80
91
|
*/
|
|
81
92
|
addCanvas(canvas: HTMLCanvasElement, url: string, renderOptions?: Partial<RenderConstructorOptionType>): void;
|
|
82
93
|
/**
|
|
83
|
-
* 初始化canvas背景
|
|
84
|
-
* @param canvas canvas
|
|
94
|
+
* 初始化canvas背景 | Initialize the canvas background
|
|
95
|
+
* @param canvas canvas
|
|
85
96
|
* @returns
|
|
86
97
|
*/
|
|
87
98
|
/**
|
|
88
|
-
* 删除canvas元素
|
|
89
|
-
* @param canvas canvas
|
|
99
|
+
* 删除canvas元素 || Remove the canvas element
|
|
100
|
+
* @param canvas canvas
|
|
90
101
|
*/
|
|
91
102
|
removeCanvas(canvas: HTMLCanvasElement): void;
|
|
92
103
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @param canvas canvas
|
|
104
|
+
* 获取canvas是否已经添加过 | Gets whether the canvas has already been added
|
|
105
|
+
* @param canvas canvas
|
|
95
106
|
* @returns boolean
|
|
96
107
|
*/
|
|
97
108
|
isCanvasExist(canvas: HTMLCanvasElement): boolean;
|
|
98
|
-
/** 设置全部render静音状态 */
|
|
109
|
+
/** 设置全部render静音状态 | Mute all render */
|
|
99
110
|
setAllVideoMutedState(muted: boolean): void;
|
|
100
|
-
/** 更新单个render实例的配置 */
|
|
111
|
+
/** 更新单个render实例的配置 | Update the configuration of a single render instance */
|
|
101
112
|
updateRenderOptions(url: string, options?: Partial<RenderConstructorOptionType>): void;
|
|
102
113
|
/**
|
|
103
|
-
* 设置单个render静音状态
|
|
114
|
+
* 设置单个render静音状态 | Set a single render to be silent
|
|
104
115
|
* @param url
|
|
105
|
-
* @param muted
|
|
116
|
+
* @param {boolean} muted 是否静音 | Muted or not
|
|
106
117
|
*/
|
|
107
118
|
setOneMutedState(url: string, muted: boolean): void;
|
|
108
119
|
/**
|
|
109
120
|
* 获取url对应render video元素是否静音
|
|
110
|
-
*
|
|
121
|
+
* Gets whether the render video element of the url is muted
|
|
122
|
+
* @param url websocket url
|
|
111
123
|
*/
|
|
112
124
|
getOneMutedState(url: string): boolean;
|
|
113
125
|
/**
|
|
114
126
|
* 单个解除静音,其他未静音的变成静音,只播放一个
|
|
115
|
-
*
|
|
127
|
+
* Unmute a single video and mute all other videos
|
|
128
|
+
* @param url websocket url
|
|
116
129
|
*/
|
|
117
130
|
playOneAudio(url: string): void;
|
|
118
131
|
/**
|
|
119
132
|
* 设置单个render是否继续处理ws数据
|
|
133
|
+
* Sets whether a single render continues to process ws data
|
|
120
134
|
* @param url
|
|
121
135
|
*/
|
|
122
136
|
setOneVideoPausedState(url: string, paused: boolean): void;
|
|
123
|
-
/** 设置全部render是否继续处理ws数据 */
|
|
137
|
+
/** 设置全部render是否继续处理ws数据 | Sets whether all render continues to process ws data */
|
|
124
138
|
setAllVideoPausedState(paused: boolean): void;
|
|
125
139
|
/**
|
|
126
|
-
* 获取url对应render video
|
|
127
|
-
*
|
|
140
|
+
* 获取url对应render video元素的播放状态
|
|
141
|
+
* Get the playback status of the render video element corresponding to the url
|
|
142
|
+
* @param url websocket url
|
|
128
143
|
*/
|
|
129
144
|
getOneVideoPausedState(url: string): boolean;
|
|
130
145
|
/**
|
|
131
146
|
* 单个视频继续播放,其他暂停处理数据
|
|
132
|
-
*
|
|
147
|
+
* A single video continues to play while others pause to process data
|
|
148
|
+
* @param url websocket url
|
|
133
149
|
*/
|
|
134
150
|
playOneVideo(url: string): void;
|
|
135
151
|
/**
|
|
136
152
|
* 刷新socket,以及播放时间
|
|
153
|
+
* Refresh the socket, and the playback time
|
|
137
154
|
*/
|
|
138
155
|
refresh(url?: string): void;
|
|
139
156
|
/**
|
|
140
|
-
* 销毁
|
|
157
|
+
* 销毁 | Destroy
|
|
141
158
|
*/
|
|
142
159
|
destroy(): void;
|
|
143
160
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 绘制视频到canvas中
|
|
2
|
+
* 绘制视频到canvas中 | Draw video into canvas
|
|
3
3
|
*/
|
|
4
4
|
declare class CanvasDrawer {
|
|
5
5
|
private _canvas;
|
|
@@ -17,27 +17,27 @@ declare class CanvasDrawer {
|
|
|
17
17
|
constructor(canvas: HTMLCanvasElement, useWebgl?: boolean);
|
|
18
18
|
private init2d;
|
|
19
19
|
/**
|
|
20
|
-
* 初始化 webgl
|
|
20
|
+
* 初始化 webgl | Initialize webgl
|
|
21
21
|
*/
|
|
22
22
|
private initGl;
|
|
23
23
|
/**
|
|
24
|
-
* 创建着色器源码
|
|
24
|
+
* 创建着色器源码 | Create shader source code
|
|
25
25
|
*/
|
|
26
26
|
private createShaderSource;
|
|
27
27
|
/**
|
|
28
|
-
* 创建着色器
|
|
28
|
+
* 创建着色器 | Create shaders
|
|
29
29
|
*/
|
|
30
30
|
private createShader;
|
|
31
31
|
/**
|
|
32
|
-
* 创建着色器程序
|
|
32
|
+
* 创建着色器程序 | Create program
|
|
33
33
|
*/
|
|
34
34
|
private createProgram;
|
|
35
35
|
/**
|
|
36
|
-
* 绘制
|
|
36
|
+
* 绘制 | draw
|
|
37
37
|
*/
|
|
38
38
|
draw(video: HTMLVideoElement): void;
|
|
39
39
|
/**
|
|
40
|
-
* 销毁
|
|
40
|
+
* 销毁 | Destroy
|
|
41
41
|
*/
|
|
42
42
|
destroy(): void;
|
|
43
43
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { EventBus } from '@havue/shared';
|
|
2
2
|
export type RenderConstructorOptionType = {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* 当前播放currentTime和最新视频时长最多相差 秒数,默认0.3s
|
|
5
|
+
* The delay of currentTime relative to the latest video duration is 0.3s by default
|
|
6
|
+
*/
|
|
4
7
|
liveMaxLatency: number;
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* 最多缓存ws传输的未处理的buffer数据大小, 默认200kb。
|
|
10
|
+
* The maximum amount of unprocessed buffer data to be cached for websocket transfers.
|
|
11
|
+
* 200kb by default
|
|
12
|
+
*/
|
|
6
13
|
maxCacheBufByte: number;
|
|
7
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* 最多存储的时间,用于清除在currentTime之前x秒时间节点前的buffer数据, 默认10s
|
|
16
|
+
* The maximum amount of time used to clear the buffer before a time node x seconds before currentTime (default 10s)
|
|
17
|
+
*/
|
|
8
18
|
maxCache: number;
|
|
9
19
|
};
|
|
10
20
|
export declare const WS_VIDEO_RENDER_DEFAULT_OPTIONS: Readonly<{
|
|
@@ -35,29 +45,32 @@ export type RenderEvents = {
|
|
|
35
45
|
[RenderEventsEnum.VIDEO_INFO_UPDATE]: (info: VideoInfo) => void;
|
|
36
46
|
};
|
|
37
47
|
export declare class Render extends EventBus<RenderEvents> {
|
|
38
|
-
/** video元素 */
|
|
48
|
+
/** video元素 | videw element */
|
|
39
49
|
private _videoEl;
|
|
40
|
-
/** mp4box
|
|
50
|
+
/** mp4box file */
|
|
41
51
|
private _mp4box;
|
|
42
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* mp4box onFragment获取的视频数据buffer数组
|
|
54
|
+
* mp4box onFragment gets a buffer array of audio and video data
|
|
55
|
+
*/
|
|
43
56
|
private _audioBufsQueue;
|
|
44
57
|
private _videoBufsQueue;
|
|
45
|
-
/** MediaSource
|
|
58
|
+
/** MediaSource instance */
|
|
46
59
|
private _mediaSource;
|
|
47
|
-
/** SourceBuffer
|
|
60
|
+
/** SourceBuffer instance */
|
|
48
61
|
private _audioSourceBuffer;
|
|
49
62
|
private _videoSourceBuffer;
|
|
50
63
|
private _audioTrackId;
|
|
51
64
|
private _videoTrackId;
|
|
52
|
-
/** 用于MediaSource的mimeType */
|
|
65
|
+
/** 用于MediaSource的mimeType | mime type of the video */
|
|
53
66
|
private _mimeType;
|
|
54
67
|
private _audioMimeType;
|
|
55
68
|
private _videoMimeType;
|
|
56
|
-
/** 是否暂停播放 */
|
|
69
|
+
/** 是否暂停播放 | Pause or not */
|
|
57
70
|
private _paused;
|
|
58
71
|
private _options;
|
|
59
72
|
private _cacheAnimationID;
|
|
60
|
-
/** fmp4初始化片段是否已经添加 */
|
|
73
|
+
/** fmp4初始化片段是否已经添加 | fmp4 Initializes whether the fragment has been added */
|
|
61
74
|
private _isAudioInitSegmentAdded;
|
|
62
75
|
private _isVideoInitSegmentAdded;
|
|
63
76
|
private _offset;
|
|
@@ -67,51 +80,54 @@ export declare class Render extends EventBus<RenderEvents> {
|
|
|
67
80
|
set paused(paused: boolean);
|
|
68
81
|
get paused(): boolean;
|
|
69
82
|
get videoEl(): HTMLVideoElement | undefined;
|
|
70
|
-
/** 更新实例配置 */
|
|
83
|
+
/** 更新实例配置 | Update configuration */
|
|
71
84
|
updateOptions(option?: Partial<RenderConstructorOptionType>): void;
|
|
72
85
|
/**
|
|
73
|
-
* 添加视频流buffer数据
|
|
86
|
+
* 添加视频流buffer数据 | Add video stream buffer data
|
|
74
87
|
* @param buf
|
|
75
88
|
*/
|
|
76
89
|
appendMediaBuffer(bufs: Array<ArrayBuffer & {
|
|
77
90
|
fileStart: number;
|
|
78
91
|
}>): void;
|
|
79
92
|
/**
|
|
80
|
-
* mp4box解析完成
|
|
81
|
-
* @param info mp4box解析信息
|
|
93
|
+
* mp4box解析完成 | handle Mp4box onReady
|
|
94
|
+
* @param info mp4box解析信息 | mp4box parses the information
|
|
82
95
|
*/
|
|
83
96
|
private _onMp4boxReady;
|
|
84
97
|
private _onSegment;
|
|
85
98
|
/**
|
|
86
|
-
* 初始化视频元素
|
|
99
|
+
* 初始化视频元素 | Initialize the video element
|
|
87
100
|
*/
|
|
88
101
|
private _setupVideo;
|
|
89
102
|
/**
|
|
90
103
|
* 是否支持Media Source Extention
|
|
104
|
+
* whether Media Source Extention is supported
|
|
91
105
|
* @returns boolean
|
|
92
106
|
*/
|
|
93
107
|
isSupportMSE(): boolean;
|
|
94
108
|
/**
|
|
95
|
-
* 初始化MSE
|
|
109
|
+
* 初始化MSE | Init MSE
|
|
96
110
|
* @returns
|
|
97
111
|
*/
|
|
98
112
|
private _setupMSE;
|
|
99
113
|
private _setupSourceBuffer;
|
|
100
114
|
/**
|
|
101
115
|
* 将_bufsQueue中的数据添加到SourceBuffer中
|
|
116
|
+
* Add the data from _bufsQueue to the SourceBuffer
|
|
102
117
|
* @returns
|
|
103
118
|
*/
|
|
104
119
|
private _cache;
|
|
105
120
|
/**
|
|
106
121
|
* 刷新播放时间为最新
|
|
122
|
+
* Refresh the playback time to the latest
|
|
107
123
|
*/
|
|
108
124
|
refresh(): void;
|
|
109
|
-
/** 重置解析的视频mime type */
|
|
125
|
+
/** 重置解析的视频mime type | Reset the parsed video mime type */
|
|
110
126
|
resetMimeType(): void;
|
|
111
127
|
private destroyMediaSource;
|
|
112
128
|
destroyMp4box(): void;
|
|
113
129
|
/**
|
|
114
|
-
* 销毁
|
|
130
|
+
* 销毁 | Destroy
|
|
115
131
|
*/
|
|
116
132
|
destroy(): void;
|
|
117
133
|
}
|
|
@@ -7312,29 +7312,32 @@ class Render extends EventBus {
|
|
|
7312
7312
|
// private divID = ''
|
|
7313
7313
|
constructor(options = {}) {
|
|
7314
7314
|
super();
|
|
7315
|
-
/** video元素 */
|
|
7315
|
+
/** video元素 | videw element */
|
|
7316
7316
|
__publicField(this, "_videoEl");
|
|
7317
|
-
/** mp4box
|
|
7317
|
+
/** mp4box file */
|
|
7318
7318
|
__publicField(this, "_mp4box", MP4Box.createFile());
|
|
7319
|
-
/**
|
|
7319
|
+
/**
|
|
7320
|
+
* mp4box onFragment获取的视频数据buffer数组
|
|
7321
|
+
* mp4box onFragment gets a buffer array of audio and video data
|
|
7322
|
+
*/
|
|
7320
7323
|
__publicField(this, "_audioBufsQueue", []);
|
|
7321
7324
|
__publicField(this, "_videoBufsQueue", []);
|
|
7322
|
-
/** MediaSource
|
|
7325
|
+
/** MediaSource instance */
|
|
7323
7326
|
__publicField(this, "_mediaSource");
|
|
7324
|
-
/** SourceBuffer
|
|
7327
|
+
/** SourceBuffer instance */
|
|
7325
7328
|
__publicField(this, "_audioSourceBuffer");
|
|
7326
7329
|
__publicField(this, "_videoSourceBuffer");
|
|
7327
7330
|
__publicField(this, "_audioTrackId");
|
|
7328
7331
|
__publicField(this, "_videoTrackId");
|
|
7329
|
-
/** 用于MediaSource的mimeType */
|
|
7332
|
+
/** 用于MediaSource的mimeType | mime type of the video */
|
|
7330
7333
|
__publicField(this, "_mimeType", "");
|
|
7331
7334
|
__publicField(this, "_audioMimeType", "");
|
|
7332
7335
|
__publicField(this, "_videoMimeType", "");
|
|
7333
|
-
/** 是否暂停播放 */
|
|
7336
|
+
/** 是否暂停播放 | Pause or not */
|
|
7334
7337
|
__publicField(this, "_paused", false);
|
|
7335
7338
|
__publicField(this, "_options");
|
|
7336
7339
|
__publicField(this, "_cacheAnimationID");
|
|
7337
|
-
/** fmp4初始化片段是否已经添加 */
|
|
7340
|
+
/** fmp4初始化片段是否已经添加 | fmp4 Initializes whether the fragment has been added */
|
|
7338
7341
|
__publicField(this, "_isAudioInitSegmentAdded", false);
|
|
7339
7342
|
__publicField(this, "_isVideoInitSegmentAdded", false);
|
|
7340
7343
|
__publicField(this, "_offset", 0);
|
|
@@ -7367,14 +7370,14 @@ class Render extends EventBus {
|
|
|
7367
7370
|
get videoEl() {
|
|
7368
7371
|
return this._videoEl;
|
|
7369
7372
|
}
|
|
7370
|
-
/** 更新实例配置 */
|
|
7373
|
+
/** 更新实例配置 | Update configuration */
|
|
7371
7374
|
updateOptions(option = {}) {
|
|
7372
7375
|
Object.assign(this._options, {
|
|
7373
7376
|
...option
|
|
7374
7377
|
});
|
|
7375
7378
|
}
|
|
7376
7379
|
/**
|
|
7377
|
-
* 添加视频流buffer数据
|
|
7380
|
+
* 添加视频流buffer数据 | Add video stream buffer data
|
|
7378
7381
|
* @param buf
|
|
7379
7382
|
*/
|
|
7380
7383
|
appendMediaBuffer(bufs) {
|
|
@@ -7389,8 +7392,8 @@ class Render extends EventBus {
|
|
|
7389
7392
|
return;
|
|
7390
7393
|
}
|
|
7391
7394
|
/**
|
|
7392
|
-
* mp4box解析完成
|
|
7393
|
-
* @param info mp4box解析信息
|
|
7395
|
+
* mp4box解析完成 | handle Mp4box onReady
|
|
7396
|
+
* @param info mp4box解析信息 | mp4box parses the information
|
|
7394
7397
|
*/
|
|
7395
7398
|
_onMp4boxReady(info) {
|
|
7396
7399
|
console.log("onMp4boxReady", info);
|
|
@@ -7467,7 +7470,7 @@ class Render extends EventBus {
|
|
|
7467
7470
|
this._cache(isVideo);
|
|
7468
7471
|
}
|
|
7469
7472
|
/**
|
|
7470
|
-
* 初始化视频元素
|
|
7473
|
+
* 初始化视频元素 | Initialize the video element
|
|
7471
7474
|
*/
|
|
7472
7475
|
_setupVideo() {
|
|
7473
7476
|
this._videoEl = document.createElement("video");
|
|
@@ -7523,13 +7526,14 @@ class Render extends EventBus {
|
|
|
7523
7526
|
}
|
|
7524
7527
|
/**
|
|
7525
7528
|
* 是否支持Media Source Extention
|
|
7529
|
+
* whether Media Source Extention is supported
|
|
7526
7530
|
* @returns boolean
|
|
7527
7531
|
*/
|
|
7528
7532
|
isSupportMSE() {
|
|
7529
7533
|
return "MediaSource" in window;
|
|
7530
7534
|
}
|
|
7531
7535
|
/**
|
|
7532
|
-
* 初始化MSE
|
|
7536
|
+
* 初始化MSE | Init MSE
|
|
7533
7537
|
* @returns
|
|
7534
7538
|
*/
|
|
7535
7539
|
_setupMSE() {
|
|
@@ -7606,6 +7610,7 @@ class Render extends EventBus {
|
|
|
7606
7610
|
}
|
|
7607
7611
|
/**
|
|
7608
7612
|
* 将_bufsQueue中的数据添加到SourceBuffer中
|
|
7613
|
+
* Add the data from _bufsQueue to the SourceBuffer
|
|
7609
7614
|
* @returns
|
|
7610
7615
|
*/
|
|
7611
7616
|
_cache(isVideo = false) {
|
|
@@ -7649,6 +7654,7 @@ class Render extends EventBus {
|
|
|
7649
7654
|
}
|
|
7650
7655
|
/**
|
|
7651
7656
|
* 刷新播放时间为最新
|
|
7657
|
+
* Refresh the playback time to the latest
|
|
7652
7658
|
*/
|
|
7653
7659
|
refresh() {
|
|
7654
7660
|
if (this._videoEl && this._videoEl.buffered.length) {
|
|
@@ -7656,7 +7662,7 @@ class Render extends EventBus {
|
|
|
7656
7662
|
this._videoEl.currentTime = end;
|
|
7657
7663
|
}
|
|
7658
7664
|
}
|
|
7659
|
-
/** 重置解析的视频mime type */
|
|
7665
|
+
/** 重置解析的视频mime type | Reset the parsed video mime type */
|
|
7660
7666
|
resetMimeType() {
|
|
7661
7667
|
this.destroyMp4box();
|
|
7662
7668
|
this.destroyMediaSource();
|
|
@@ -7707,7 +7713,7 @@ class Render extends EventBus {
|
|
|
7707
7713
|
this._mp4box = null;
|
|
7708
7714
|
}
|
|
7709
7715
|
/**
|
|
7710
|
-
* 销毁
|
|
7716
|
+
* 销毁 | Destroy
|
|
7711
7717
|
*/
|
|
7712
7718
|
destroy() {
|
|
7713
7719
|
if (this._videoEl) {
|
|
@@ -7758,7 +7764,7 @@ class CanvasDrawer {
|
|
|
7758
7764
|
this._ctx2d.fillRect(0, 0, this._canvas.width, this._canvas.height);
|
|
7759
7765
|
}
|
|
7760
7766
|
/**
|
|
7761
|
-
* 初始化 webgl
|
|
7767
|
+
* 初始化 webgl | Initialize webgl
|
|
7762
7768
|
*/
|
|
7763
7769
|
initGl() {
|
|
7764
7770
|
if (!this._canvas) return;
|
|
@@ -7800,7 +7806,7 @@ class CanvasDrawer {
|
|
|
7800
7806
|
this._glReady = true;
|
|
7801
7807
|
}
|
|
7802
7808
|
/**
|
|
7803
|
-
* 创建着色器源码
|
|
7809
|
+
* 创建着色器源码 | Create shader source code
|
|
7804
7810
|
*/
|
|
7805
7811
|
createShaderSource(gl, type) {
|
|
7806
7812
|
const vertexShaderSource = `
|
|
@@ -7827,7 +7833,7 @@ class CanvasDrawer {
|
|
|
7827
7833
|
}
|
|
7828
7834
|
}
|
|
7829
7835
|
/**
|
|
7830
|
-
* 创建着色器
|
|
7836
|
+
* 创建着色器 | Create shaders
|
|
7831
7837
|
*/
|
|
7832
7838
|
createShader(gl, type, source) {
|
|
7833
7839
|
const shader = gl.createShader(type);
|
|
@@ -7845,7 +7851,7 @@ class CanvasDrawer {
|
|
|
7845
7851
|
return shader;
|
|
7846
7852
|
}
|
|
7847
7853
|
/**
|
|
7848
|
-
* 创建着色器程序
|
|
7854
|
+
* 创建着色器程序 | Create program
|
|
7849
7855
|
*/
|
|
7850
7856
|
createProgram(gl, vertexShader, fragmentShader) {
|
|
7851
7857
|
const program = gl.createProgram();
|
|
@@ -7864,7 +7870,7 @@ class CanvasDrawer {
|
|
|
7864
7870
|
return program;
|
|
7865
7871
|
}
|
|
7866
7872
|
/**
|
|
7867
|
-
* 绘制
|
|
7873
|
+
* 绘制 | draw
|
|
7868
7874
|
*/
|
|
7869
7875
|
draw(video) {
|
|
7870
7876
|
if (this._useGl) {
|
|
@@ -7903,7 +7909,7 @@ class CanvasDrawer {
|
|
|
7903
7909
|
}
|
|
7904
7910
|
}
|
|
7905
7911
|
/**
|
|
7906
|
-
* 销毁
|
|
7912
|
+
* 销毁 | Destroy
|
|
7907
7913
|
*/
|
|
7908
7914
|
destroy() {
|
|
7909
7915
|
this._canvas = null;
|
|
@@ -7939,7 +7945,7 @@ const WsVideoManagerEventEnums = Object.assign({}, EventEnums, RenderEventsEnum)
|
|
|
7939
7945
|
class WsVideoManager extends EventBus {
|
|
7940
7946
|
constructor(options) {
|
|
7941
7947
|
super();
|
|
7942
|
-
/** socket
|
|
7948
|
+
/** socket相关信息map | map of socket information */
|
|
7943
7949
|
__publicField(this, "_wsInfoMap", /* @__PURE__ */ new Map());
|
|
7944
7950
|
__publicField(this, "_option", DEFAULT_OPTIONS);
|
|
7945
7951
|
__publicField(this, "_reqAnimationID", null);
|
|
@@ -7972,8 +7978,8 @@ class WsVideoManager extends EventBus {
|
|
|
7972
7978
|
render();
|
|
7973
7979
|
}
|
|
7974
7980
|
/**
|
|
7975
|
-
* 添加socket
|
|
7976
|
-
* @param url socket
|
|
7981
|
+
* 添加socket连接 | Adding a socket connection
|
|
7982
|
+
* @param url socket url
|
|
7977
7983
|
* @returns
|
|
7978
7984
|
*/
|
|
7979
7985
|
_addSocket(url, renderOptions) {
|
|
@@ -8002,9 +8008,9 @@ class WsVideoManager extends EventBus {
|
|
|
8002
8008
|
socket.open();
|
|
8003
8009
|
}
|
|
8004
8010
|
/**
|
|
8005
|
-
* 绑定render事件
|
|
8006
|
-
* @param url 连接地址
|
|
8007
|
-
* @param render Render
|
|
8011
|
+
* 绑定render事件 | Binding the render event
|
|
8012
|
+
* @param url 连接地址 | websocket url
|
|
8013
|
+
* @param render Render instance
|
|
8008
8014
|
*/
|
|
8009
8015
|
_bindRenderEvent(url, render) {
|
|
8010
8016
|
render.on(RenderEventsEnum.AUDIO_STATE_CHANGE, (state) => {
|
|
@@ -8018,8 +8024,8 @@ class WsVideoManager extends EventBus {
|
|
|
8018
8024
|
});
|
|
8019
8025
|
}
|
|
8020
8026
|
/**
|
|
8021
|
-
*
|
|
8022
|
-
* @param url socket
|
|
8027
|
+
* Destroying the socket connect
|
|
8028
|
+
* @param url socket url
|
|
8023
8029
|
*/
|
|
8024
8030
|
_removeSocket(url) {
|
|
8025
8031
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8033,9 +8039,9 @@ class WsVideoManager extends EventBus {
|
|
|
8033
8039
|
}
|
|
8034
8040
|
}
|
|
8035
8041
|
/**
|
|
8036
|
-
* 绑定socket事件
|
|
8037
|
-
* @param url
|
|
8038
|
-
* @param socket WebSocketLoader
|
|
8042
|
+
* 绑定socket事件 | Binding socket events
|
|
8043
|
+
* @param url websocket url
|
|
8044
|
+
* @param socket WebSocketLoader instance
|
|
8039
8045
|
*/
|
|
8040
8046
|
_bindSocketEvent(socket, render, url) {
|
|
8041
8047
|
socket.on("close", () => {
|
|
@@ -8065,8 +8071,8 @@ class WsVideoManager extends EventBus {
|
|
|
8065
8071
|
}
|
|
8066
8072
|
}
|
|
8067
8073
|
/**
|
|
8068
|
-
* url对应的 socket实例是否已存在
|
|
8069
|
-
* @param url
|
|
8074
|
+
* url对应的 socket实例是否已存在 | Whether the socket instance for the url already exists
|
|
8075
|
+
* @param url websocket url
|
|
8070
8076
|
* @returns boolean
|
|
8071
8077
|
*/
|
|
8072
8078
|
_isSocketExist(url) {
|
|
@@ -8074,8 +8080,9 @@ class WsVideoManager extends EventBus {
|
|
|
8074
8080
|
}
|
|
8075
8081
|
/**
|
|
8076
8082
|
* 添加url对应socket,以及需要绘制的canvas元素
|
|
8077
|
-
*
|
|
8078
|
-
* @param
|
|
8083
|
+
* Add the socket for the url and the canvas element to draw
|
|
8084
|
+
* @param canvas canvas
|
|
8085
|
+
* @param url websocket url
|
|
8079
8086
|
*/
|
|
8080
8087
|
addCanvas(canvas, url, renderOptions) {
|
|
8081
8088
|
this._addSocket(url, renderOptions);
|
|
@@ -8094,8 +8101,8 @@ class WsVideoManager extends EventBus {
|
|
|
8094
8101
|
}
|
|
8095
8102
|
}
|
|
8096
8103
|
/**
|
|
8097
|
-
* 初始化canvas背景
|
|
8098
|
-
* @param canvas canvas
|
|
8104
|
+
* 初始化canvas背景 | Initialize the canvas background
|
|
8105
|
+
* @param canvas canvas
|
|
8099
8106
|
* @returns
|
|
8100
8107
|
*/
|
|
8101
8108
|
// private _setupCanvas(canvas: HTMLCanvasElement) {
|
|
@@ -8107,8 +8114,8 @@ class WsVideoManager extends EventBus {
|
|
|
8107
8114
|
// ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
8108
8115
|
// }
|
|
8109
8116
|
/**
|
|
8110
|
-
* 删除canvas元素
|
|
8111
|
-
* @param canvas canvas
|
|
8117
|
+
* 删除canvas元素 || Remove the canvas element
|
|
8118
|
+
* @param canvas canvas
|
|
8112
8119
|
*/
|
|
8113
8120
|
removeCanvas(canvas) {
|
|
8114
8121
|
const entries = this._wsInfoMap.entries();
|
|
@@ -8127,8 +8134,8 @@ class WsVideoManager extends EventBus {
|
|
|
8127
8134
|
});
|
|
8128
8135
|
}
|
|
8129
8136
|
/**
|
|
8130
|
-
*
|
|
8131
|
-
* @param canvas canvas
|
|
8137
|
+
* 获取canvas是否已经添加过 | Gets whether the canvas has already been added
|
|
8138
|
+
* @param canvas canvas
|
|
8132
8139
|
* @returns boolean
|
|
8133
8140
|
*/
|
|
8134
8141
|
isCanvasExist(canvas) {
|
|
@@ -8137,13 +8144,13 @@ class WsVideoManager extends EventBus {
|
|
|
8137
8144
|
return info.canvasMap.has(canvas);
|
|
8138
8145
|
});
|
|
8139
8146
|
}
|
|
8140
|
-
/** 设置全部render静音状态 */
|
|
8147
|
+
/** 设置全部render静音状态 | Mute all render */
|
|
8141
8148
|
setAllVideoMutedState(muted) {
|
|
8142
8149
|
this._wsInfoMap.forEach((wsInfo) => {
|
|
8143
8150
|
wsInfo.render.muted = muted;
|
|
8144
8151
|
});
|
|
8145
8152
|
}
|
|
8146
|
-
/** 更新单个render实例的配置 */
|
|
8153
|
+
/** 更新单个render实例的配置 | Update the configuration of a single render instance */
|
|
8147
8154
|
updateRenderOptions(url, options) {
|
|
8148
8155
|
if (options) {
|
|
8149
8156
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8151,9 +8158,9 @@ class WsVideoManager extends EventBus {
|
|
|
8151
8158
|
}
|
|
8152
8159
|
}
|
|
8153
8160
|
/**
|
|
8154
|
-
* 设置单个render静音状态
|
|
8161
|
+
* 设置单个render静音状态 | Set a single render to be silent
|
|
8155
8162
|
* @param url
|
|
8156
|
-
* @param muted
|
|
8163
|
+
* @param {boolean} muted 是否静音 | Muted or not
|
|
8157
8164
|
*/
|
|
8158
8165
|
setOneMutedState(url, muted) {
|
|
8159
8166
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8164,7 +8171,8 @@ class WsVideoManager extends EventBus {
|
|
|
8164
8171
|
}
|
|
8165
8172
|
/**
|
|
8166
8173
|
* 获取url对应render video元素是否静音
|
|
8167
|
-
*
|
|
8174
|
+
* Gets whether the render video element of the url is muted
|
|
8175
|
+
* @param url websocket url
|
|
8168
8176
|
*/
|
|
8169
8177
|
getOneMutedState(url) {
|
|
8170
8178
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8175,7 +8183,8 @@ class WsVideoManager extends EventBus {
|
|
|
8175
8183
|
}
|
|
8176
8184
|
/**
|
|
8177
8185
|
* 单个解除静音,其他未静音的变成静音,只播放一个
|
|
8178
|
-
*
|
|
8186
|
+
* Unmute a single video and mute all other videos
|
|
8187
|
+
* @param url websocket url
|
|
8179
8188
|
*/
|
|
8180
8189
|
playOneAudio(url) {
|
|
8181
8190
|
this.setAllVideoMutedState(true);
|
|
@@ -8183,6 +8192,7 @@ class WsVideoManager extends EventBus {
|
|
|
8183
8192
|
}
|
|
8184
8193
|
/**
|
|
8185
8194
|
* 设置单个render是否继续处理ws数据
|
|
8195
|
+
* Sets whether a single render continues to process ws data
|
|
8186
8196
|
* @param url
|
|
8187
8197
|
*/
|
|
8188
8198
|
setOneVideoPausedState(url, paused) {
|
|
@@ -8192,15 +8202,16 @@ class WsVideoManager extends EventBus {
|
|
|
8192
8202
|
}
|
|
8193
8203
|
wsInfo.render.paused = paused;
|
|
8194
8204
|
}
|
|
8195
|
-
/** 设置全部render是否继续处理ws数据 */
|
|
8205
|
+
/** 设置全部render是否继续处理ws数据 | Sets whether all render continues to process ws data */
|
|
8196
8206
|
setAllVideoPausedState(paused) {
|
|
8197
8207
|
this._wsInfoMap.forEach((wsInfo) => {
|
|
8198
8208
|
wsInfo.render.paused = paused;
|
|
8199
8209
|
});
|
|
8200
8210
|
}
|
|
8201
8211
|
/**
|
|
8202
|
-
* 获取url对应render video
|
|
8203
|
-
*
|
|
8212
|
+
* 获取url对应render video元素的播放状态
|
|
8213
|
+
* Get the playback status of the render video element corresponding to the url
|
|
8214
|
+
* @param url websocket url
|
|
8204
8215
|
*/
|
|
8205
8216
|
getOneVideoPausedState(url) {
|
|
8206
8217
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8211,7 +8222,8 @@ class WsVideoManager extends EventBus {
|
|
|
8211
8222
|
}
|
|
8212
8223
|
/**
|
|
8213
8224
|
* 单个视频继续播放,其他暂停处理数据
|
|
8214
|
-
*
|
|
8225
|
+
* A single video continues to play while others pause to process data
|
|
8226
|
+
* @param url websocket url
|
|
8215
8227
|
*/
|
|
8216
8228
|
playOneVideo(url) {
|
|
8217
8229
|
this.setAllVideoPausedState(true);
|
|
@@ -8219,6 +8231,7 @@ class WsVideoManager extends EventBus {
|
|
|
8219
8231
|
}
|
|
8220
8232
|
/**
|
|
8221
8233
|
* 刷新socket,以及播放时间
|
|
8234
|
+
* Refresh the socket, and the playback time
|
|
8222
8235
|
*/
|
|
8223
8236
|
refresh(url) {
|
|
8224
8237
|
if (url) {
|
|
@@ -8239,7 +8252,7 @@ class WsVideoManager extends EventBus {
|
|
|
8239
8252
|
}
|
|
8240
8253
|
}
|
|
8241
8254
|
/**
|
|
8242
|
-
* 销毁
|
|
8255
|
+
* 销毁 | Destroy
|
|
8243
8256
|
*/
|
|
8244
8257
|
destroy() {
|
|
8245
8258
|
this._wsInfoMap.forEach((wsInfo) => {
|
|
@@ -7315,29 +7315,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7315
7315
|
// private divID = ''
|
|
7316
7316
|
constructor(options = {}) {
|
|
7317
7317
|
super();
|
|
7318
|
-
/** video元素 */
|
|
7318
|
+
/** video元素 | videw element */
|
|
7319
7319
|
__publicField(this, "_videoEl");
|
|
7320
|
-
/** mp4box
|
|
7320
|
+
/** mp4box file */
|
|
7321
7321
|
__publicField(this, "_mp4box", MP4Box.createFile());
|
|
7322
|
-
/**
|
|
7322
|
+
/**
|
|
7323
|
+
* mp4box onFragment获取的视频数据buffer数组
|
|
7324
|
+
* mp4box onFragment gets a buffer array of audio and video data
|
|
7325
|
+
*/
|
|
7323
7326
|
__publicField(this, "_audioBufsQueue", []);
|
|
7324
7327
|
__publicField(this, "_videoBufsQueue", []);
|
|
7325
|
-
/** MediaSource
|
|
7328
|
+
/** MediaSource instance */
|
|
7326
7329
|
__publicField(this, "_mediaSource");
|
|
7327
|
-
/** SourceBuffer
|
|
7330
|
+
/** SourceBuffer instance */
|
|
7328
7331
|
__publicField(this, "_audioSourceBuffer");
|
|
7329
7332
|
__publicField(this, "_videoSourceBuffer");
|
|
7330
7333
|
__publicField(this, "_audioTrackId");
|
|
7331
7334
|
__publicField(this, "_videoTrackId");
|
|
7332
|
-
/** 用于MediaSource的mimeType */
|
|
7335
|
+
/** 用于MediaSource的mimeType | mime type of the video */
|
|
7333
7336
|
__publicField(this, "_mimeType", "");
|
|
7334
7337
|
__publicField(this, "_audioMimeType", "");
|
|
7335
7338
|
__publicField(this, "_videoMimeType", "");
|
|
7336
|
-
/** 是否暂停播放 */
|
|
7339
|
+
/** 是否暂停播放 | Pause or not */
|
|
7337
7340
|
__publicField(this, "_paused", false);
|
|
7338
7341
|
__publicField(this, "_options");
|
|
7339
7342
|
__publicField(this, "_cacheAnimationID");
|
|
7340
|
-
/** fmp4初始化片段是否已经添加 */
|
|
7343
|
+
/** fmp4初始化片段是否已经添加 | fmp4 Initializes whether the fragment has been added */
|
|
7341
7344
|
__publicField(this, "_isAudioInitSegmentAdded", false);
|
|
7342
7345
|
__publicField(this, "_isVideoInitSegmentAdded", false);
|
|
7343
7346
|
__publicField(this, "_offset", 0);
|
|
@@ -7370,14 +7373,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7370
7373
|
get videoEl() {
|
|
7371
7374
|
return this._videoEl;
|
|
7372
7375
|
}
|
|
7373
|
-
/** 更新实例配置 */
|
|
7376
|
+
/** 更新实例配置 | Update configuration */
|
|
7374
7377
|
updateOptions(option = {}) {
|
|
7375
7378
|
Object.assign(this._options, {
|
|
7376
7379
|
...option
|
|
7377
7380
|
});
|
|
7378
7381
|
}
|
|
7379
7382
|
/**
|
|
7380
|
-
* 添加视频流buffer数据
|
|
7383
|
+
* 添加视频流buffer数据 | Add video stream buffer data
|
|
7381
7384
|
* @param buf
|
|
7382
7385
|
*/
|
|
7383
7386
|
appendMediaBuffer(bufs) {
|
|
@@ -7392,8 +7395,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7392
7395
|
return;
|
|
7393
7396
|
}
|
|
7394
7397
|
/**
|
|
7395
|
-
* mp4box解析完成
|
|
7396
|
-
* @param info mp4box解析信息
|
|
7398
|
+
* mp4box解析完成 | handle Mp4box onReady
|
|
7399
|
+
* @param info mp4box解析信息 | mp4box parses the information
|
|
7397
7400
|
*/
|
|
7398
7401
|
_onMp4boxReady(info) {
|
|
7399
7402
|
console.log("onMp4boxReady", info);
|
|
@@ -7470,7 +7473,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7470
7473
|
this._cache(isVideo);
|
|
7471
7474
|
}
|
|
7472
7475
|
/**
|
|
7473
|
-
* 初始化视频元素
|
|
7476
|
+
* 初始化视频元素 | Initialize the video element
|
|
7474
7477
|
*/
|
|
7475
7478
|
_setupVideo() {
|
|
7476
7479
|
this._videoEl = document.createElement("video");
|
|
@@ -7526,13 +7529,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7526
7529
|
}
|
|
7527
7530
|
/**
|
|
7528
7531
|
* 是否支持Media Source Extention
|
|
7532
|
+
* whether Media Source Extention is supported
|
|
7529
7533
|
* @returns boolean
|
|
7530
7534
|
*/
|
|
7531
7535
|
isSupportMSE() {
|
|
7532
7536
|
return "MediaSource" in window;
|
|
7533
7537
|
}
|
|
7534
7538
|
/**
|
|
7535
|
-
* 初始化MSE
|
|
7539
|
+
* 初始化MSE | Init MSE
|
|
7536
7540
|
* @returns
|
|
7537
7541
|
*/
|
|
7538
7542
|
_setupMSE() {
|
|
@@ -7609,6 +7613,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7609
7613
|
}
|
|
7610
7614
|
/**
|
|
7611
7615
|
* 将_bufsQueue中的数据添加到SourceBuffer中
|
|
7616
|
+
* Add the data from _bufsQueue to the SourceBuffer
|
|
7612
7617
|
* @returns
|
|
7613
7618
|
*/
|
|
7614
7619
|
_cache(isVideo = false) {
|
|
@@ -7652,6 +7657,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7652
7657
|
}
|
|
7653
7658
|
/**
|
|
7654
7659
|
* 刷新播放时间为最新
|
|
7660
|
+
* Refresh the playback time to the latest
|
|
7655
7661
|
*/
|
|
7656
7662
|
refresh() {
|
|
7657
7663
|
if (this._videoEl && this._videoEl.buffered.length) {
|
|
@@ -7659,7 +7665,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7659
7665
|
this._videoEl.currentTime = end;
|
|
7660
7666
|
}
|
|
7661
7667
|
}
|
|
7662
|
-
/** 重置解析的视频mime type */
|
|
7668
|
+
/** 重置解析的视频mime type | Reset the parsed video mime type */
|
|
7663
7669
|
resetMimeType() {
|
|
7664
7670
|
this.destroyMp4box();
|
|
7665
7671
|
this.destroyMediaSource();
|
|
@@ -7710,7 +7716,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7710
7716
|
this._mp4box = null;
|
|
7711
7717
|
}
|
|
7712
7718
|
/**
|
|
7713
|
-
* 销毁
|
|
7719
|
+
* 销毁 | Destroy
|
|
7714
7720
|
*/
|
|
7715
7721
|
destroy() {
|
|
7716
7722
|
if (this._videoEl) {
|
|
@@ -7761,7 +7767,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7761
7767
|
this._ctx2d.fillRect(0, 0, this._canvas.width, this._canvas.height);
|
|
7762
7768
|
}
|
|
7763
7769
|
/**
|
|
7764
|
-
* 初始化 webgl
|
|
7770
|
+
* 初始化 webgl | Initialize webgl
|
|
7765
7771
|
*/
|
|
7766
7772
|
initGl() {
|
|
7767
7773
|
if (!this._canvas) return;
|
|
@@ -7803,7 +7809,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7803
7809
|
this._glReady = true;
|
|
7804
7810
|
}
|
|
7805
7811
|
/**
|
|
7806
|
-
* 创建着色器源码
|
|
7812
|
+
* 创建着色器源码 | Create shader source code
|
|
7807
7813
|
*/
|
|
7808
7814
|
createShaderSource(gl, type) {
|
|
7809
7815
|
const vertexShaderSource = `
|
|
@@ -7830,7 +7836,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7830
7836
|
}
|
|
7831
7837
|
}
|
|
7832
7838
|
/**
|
|
7833
|
-
* 创建着色器
|
|
7839
|
+
* 创建着色器 | Create shaders
|
|
7834
7840
|
*/
|
|
7835
7841
|
createShader(gl, type, source) {
|
|
7836
7842
|
const shader = gl.createShader(type);
|
|
@@ -7848,7 +7854,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7848
7854
|
return shader;
|
|
7849
7855
|
}
|
|
7850
7856
|
/**
|
|
7851
|
-
* 创建着色器程序
|
|
7857
|
+
* 创建着色器程序 | Create program
|
|
7852
7858
|
*/
|
|
7853
7859
|
createProgram(gl, vertexShader, fragmentShader) {
|
|
7854
7860
|
const program = gl.createProgram();
|
|
@@ -7867,7 +7873,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7867
7873
|
return program;
|
|
7868
7874
|
}
|
|
7869
7875
|
/**
|
|
7870
|
-
* 绘制
|
|
7876
|
+
* 绘制 | draw
|
|
7871
7877
|
*/
|
|
7872
7878
|
draw(video) {
|
|
7873
7879
|
if (this._useGl) {
|
|
@@ -7906,7 +7912,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7906
7912
|
}
|
|
7907
7913
|
}
|
|
7908
7914
|
/**
|
|
7909
|
-
* 销毁
|
|
7915
|
+
* 销毁 | Destroy
|
|
7910
7916
|
*/
|
|
7911
7917
|
destroy() {
|
|
7912
7918
|
this._canvas = null;
|
|
@@ -7942,7 +7948,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7942
7948
|
class WsVideoManager extends shared.EventBus {
|
|
7943
7949
|
constructor(options) {
|
|
7944
7950
|
super();
|
|
7945
|
-
/** socket
|
|
7951
|
+
/** socket相关信息map | map of socket information */
|
|
7946
7952
|
__publicField(this, "_wsInfoMap", /* @__PURE__ */ new Map());
|
|
7947
7953
|
__publicField(this, "_option", DEFAULT_OPTIONS);
|
|
7948
7954
|
__publicField(this, "_reqAnimationID", null);
|
|
@@ -7975,8 +7981,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7975
7981
|
render();
|
|
7976
7982
|
}
|
|
7977
7983
|
/**
|
|
7978
|
-
* 添加socket
|
|
7979
|
-
* @param url socket
|
|
7984
|
+
* 添加socket连接 | Adding a socket connection
|
|
7985
|
+
* @param url socket url
|
|
7980
7986
|
* @returns
|
|
7981
7987
|
*/
|
|
7982
7988
|
_addSocket(url, renderOptions) {
|
|
@@ -8005,9 +8011,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8005
8011
|
socket.open();
|
|
8006
8012
|
}
|
|
8007
8013
|
/**
|
|
8008
|
-
* 绑定render事件
|
|
8009
|
-
* @param url 连接地址
|
|
8010
|
-
* @param render Render
|
|
8014
|
+
* 绑定render事件 | Binding the render event
|
|
8015
|
+
* @param url 连接地址 | websocket url
|
|
8016
|
+
* @param render Render instance
|
|
8011
8017
|
*/
|
|
8012
8018
|
_bindRenderEvent(url, render) {
|
|
8013
8019
|
render.on(RenderEventsEnum.AUDIO_STATE_CHANGE, (state) => {
|
|
@@ -8021,8 +8027,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8021
8027
|
});
|
|
8022
8028
|
}
|
|
8023
8029
|
/**
|
|
8024
|
-
*
|
|
8025
|
-
* @param url socket
|
|
8030
|
+
* Destroying the socket connect
|
|
8031
|
+
* @param url socket url
|
|
8026
8032
|
*/
|
|
8027
8033
|
_removeSocket(url) {
|
|
8028
8034
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8036,9 +8042,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8036
8042
|
}
|
|
8037
8043
|
}
|
|
8038
8044
|
/**
|
|
8039
|
-
* 绑定socket事件
|
|
8040
|
-
* @param url
|
|
8041
|
-
* @param socket WebSocketLoader
|
|
8045
|
+
* 绑定socket事件 | Binding socket events
|
|
8046
|
+
* @param url websocket url
|
|
8047
|
+
* @param socket WebSocketLoader instance
|
|
8042
8048
|
*/
|
|
8043
8049
|
_bindSocketEvent(socket, render, url) {
|
|
8044
8050
|
socket.on("close", () => {
|
|
@@ -8068,8 +8074,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8068
8074
|
}
|
|
8069
8075
|
}
|
|
8070
8076
|
/**
|
|
8071
|
-
* url对应的 socket实例是否已存在
|
|
8072
|
-
* @param url
|
|
8077
|
+
* url对应的 socket实例是否已存在 | Whether the socket instance for the url already exists
|
|
8078
|
+
* @param url websocket url
|
|
8073
8079
|
* @returns boolean
|
|
8074
8080
|
*/
|
|
8075
8081
|
_isSocketExist(url) {
|
|
@@ -8077,8 +8083,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8077
8083
|
}
|
|
8078
8084
|
/**
|
|
8079
8085
|
* 添加url对应socket,以及需要绘制的canvas元素
|
|
8080
|
-
*
|
|
8081
|
-
* @param
|
|
8086
|
+
* Add the socket for the url and the canvas element to draw
|
|
8087
|
+
* @param canvas canvas
|
|
8088
|
+
* @param url websocket url
|
|
8082
8089
|
*/
|
|
8083
8090
|
addCanvas(canvas, url, renderOptions) {
|
|
8084
8091
|
this._addSocket(url, renderOptions);
|
|
@@ -8097,8 +8104,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8097
8104
|
}
|
|
8098
8105
|
}
|
|
8099
8106
|
/**
|
|
8100
|
-
* 初始化canvas背景
|
|
8101
|
-
* @param canvas canvas
|
|
8107
|
+
* 初始化canvas背景 | Initialize the canvas background
|
|
8108
|
+
* @param canvas canvas
|
|
8102
8109
|
* @returns
|
|
8103
8110
|
*/
|
|
8104
8111
|
// private _setupCanvas(canvas: HTMLCanvasElement) {
|
|
@@ -8110,8 +8117,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8110
8117
|
// ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
8111
8118
|
// }
|
|
8112
8119
|
/**
|
|
8113
|
-
* 删除canvas元素
|
|
8114
|
-
* @param canvas canvas
|
|
8120
|
+
* 删除canvas元素 || Remove the canvas element
|
|
8121
|
+
* @param canvas canvas
|
|
8115
8122
|
*/
|
|
8116
8123
|
removeCanvas(canvas) {
|
|
8117
8124
|
const entries = this._wsInfoMap.entries();
|
|
@@ -8130,8 +8137,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8130
8137
|
});
|
|
8131
8138
|
}
|
|
8132
8139
|
/**
|
|
8133
|
-
*
|
|
8134
|
-
* @param canvas canvas
|
|
8140
|
+
* 获取canvas是否已经添加过 | Gets whether the canvas has already been added
|
|
8141
|
+
* @param canvas canvas
|
|
8135
8142
|
* @returns boolean
|
|
8136
8143
|
*/
|
|
8137
8144
|
isCanvasExist(canvas) {
|
|
@@ -8140,13 +8147,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8140
8147
|
return info.canvasMap.has(canvas);
|
|
8141
8148
|
});
|
|
8142
8149
|
}
|
|
8143
|
-
/** 设置全部render静音状态 */
|
|
8150
|
+
/** 设置全部render静音状态 | Mute all render */
|
|
8144
8151
|
setAllVideoMutedState(muted) {
|
|
8145
8152
|
this._wsInfoMap.forEach((wsInfo) => {
|
|
8146
8153
|
wsInfo.render.muted = muted;
|
|
8147
8154
|
});
|
|
8148
8155
|
}
|
|
8149
|
-
/** 更新单个render实例的配置 */
|
|
8156
|
+
/** 更新单个render实例的配置 | Update the configuration of a single render instance */
|
|
8150
8157
|
updateRenderOptions(url, options) {
|
|
8151
8158
|
if (options) {
|
|
8152
8159
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8154,9 +8161,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8154
8161
|
}
|
|
8155
8162
|
}
|
|
8156
8163
|
/**
|
|
8157
|
-
* 设置单个render静音状态
|
|
8164
|
+
* 设置单个render静音状态 | Set a single render to be silent
|
|
8158
8165
|
* @param url
|
|
8159
|
-
* @param muted
|
|
8166
|
+
* @param {boolean} muted 是否静音 | Muted or not
|
|
8160
8167
|
*/
|
|
8161
8168
|
setOneMutedState(url, muted) {
|
|
8162
8169
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8167,7 +8174,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8167
8174
|
}
|
|
8168
8175
|
/**
|
|
8169
8176
|
* 获取url对应render video元素是否静音
|
|
8170
|
-
*
|
|
8177
|
+
* Gets whether the render video element of the url is muted
|
|
8178
|
+
* @param url websocket url
|
|
8171
8179
|
*/
|
|
8172
8180
|
getOneMutedState(url) {
|
|
8173
8181
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8178,7 +8186,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8178
8186
|
}
|
|
8179
8187
|
/**
|
|
8180
8188
|
* 单个解除静音,其他未静音的变成静音,只播放一个
|
|
8181
|
-
*
|
|
8189
|
+
* Unmute a single video and mute all other videos
|
|
8190
|
+
* @param url websocket url
|
|
8182
8191
|
*/
|
|
8183
8192
|
playOneAudio(url) {
|
|
8184
8193
|
this.setAllVideoMutedState(true);
|
|
@@ -8186,6 +8195,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8186
8195
|
}
|
|
8187
8196
|
/**
|
|
8188
8197
|
* 设置单个render是否继续处理ws数据
|
|
8198
|
+
* Sets whether a single render continues to process ws data
|
|
8189
8199
|
* @param url
|
|
8190
8200
|
*/
|
|
8191
8201
|
setOneVideoPausedState(url, paused) {
|
|
@@ -8195,15 +8205,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8195
8205
|
}
|
|
8196
8206
|
wsInfo.render.paused = paused;
|
|
8197
8207
|
}
|
|
8198
|
-
/** 设置全部render是否继续处理ws数据 */
|
|
8208
|
+
/** 设置全部render是否继续处理ws数据 | Sets whether all render continues to process ws data */
|
|
8199
8209
|
setAllVideoPausedState(paused) {
|
|
8200
8210
|
this._wsInfoMap.forEach((wsInfo) => {
|
|
8201
8211
|
wsInfo.render.paused = paused;
|
|
8202
8212
|
});
|
|
8203
8213
|
}
|
|
8204
8214
|
/**
|
|
8205
|
-
* 获取url对应render video
|
|
8206
|
-
*
|
|
8215
|
+
* 获取url对应render video元素的播放状态
|
|
8216
|
+
* Get the playback status of the render video element corresponding to the url
|
|
8217
|
+
* @param url websocket url
|
|
8207
8218
|
*/
|
|
8208
8219
|
getOneVideoPausedState(url) {
|
|
8209
8220
|
const wsInfo = this._wsInfoMap.get(url);
|
|
@@ -8214,7 +8225,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8214
8225
|
}
|
|
8215
8226
|
/**
|
|
8216
8227
|
* 单个视频继续播放,其他暂停处理数据
|
|
8217
|
-
*
|
|
8228
|
+
* A single video continues to play while others pause to process data
|
|
8229
|
+
* @param url websocket url
|
|
8218
8230
|
*/
|
|
8219
8231
|
playOneVideo(url) {
|
|
8220
8232
|
this.setAllVideoPausedState(true);
|
|
@@ -8222,6 +8234,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8222
8234
|
}
|
|
8223
8235
|
/**
|
|
8224
8236
|
* 刷新socket,以及播放时间
|
|
8237
|
+
* Refresh the socket, and the playback time
|
|
8225
8238
|
*/
|
|
8226
8239
|
refresh(url) {
|
|
8227
8240
|
if (url) {
|
|
@@ -8242,7 +8255,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8242
8255
|
}
|
|
8243
8256
|
}
|
|
8244
8257
|
/**
|
|
8245
|
-
* 销毁
|
|
8258
|
+
* 销毁 | Destroy
|
|
8246
8259
|
*/
|
|
8247
8260
|
destroy() {
|
|
8248
8261
|
this._wsInfoMap.forEach((wsInfo) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@havue/ws-video-manager",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Javascript class for websocket video manager",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"havue",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@vueuse/core": "^11.0.3",
|
|
19
|
-
"@havue/shared": "^1.1
|
|
19
|
+
"@havue/shared": "^1.2.1"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public",
|