easy-player-pro 0.1.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/README.md +127 -0
- package/lib/build/EasyPlayer-decode.js +1 -0
- package/lib/build/EasyPlayer-lib.js +1 -0
- package/lib/build/EasyPlayer-pro.js +1 -0
- package/lib/build/EasyPlayer-pro.wasm +0 -0
- package/lib/build/EasyPlayer-snap.wasm +0 -0
- package/lib/core/config.js +117 -0
- package/lib/core/easy-player-pro.js +265 -0
- package/lib/core/easy-player.js +265 -0
- package/lib/index.js +2 -0
- package/lib/types/core/config.d.ts +118 -0
- package/lib/types/core/easy-player-pro.d.ts +177 -0
- package/lib/types/core/easy-player.d.ts +177 -0
- package/lib/types/index.d.ts +5 -0
- package/package.json +51 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export const defaultConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* 是否直播
|
|
4
|
+
*/
|
|
5
|
+
isLive: true,
|
|
6
|
+
/**
|
|
7
|
+
* 是否解析音频
|
|
8
|
+
*/
|
|
9
|
+
hasAudio: true,
|
|
10
|
+
/**
|
|
11
|
+
* 是否渲染音频
|
|
12
|
+
*/
|
|
13
|
+
isMute: false,
|
|
14
|
+
/**
|
|
15
|
+
* 视频拉伸
|
|
16
|
+
*/
|
|
17
|
+
stretch: false,
|
|
18
|
+
/**
|
|
19
|
+
* 视频封面图片
|
|
20
|
+
*/
|
|
21
|
+
poster: true,
|
|
22
|
+
/**
|
|
23
|
+
* 加载显设置最小缓冲时长,单位秒,播放器会自动消除延迟。
|
|
24
|
+
*/
|
|
25
|
+
bufferTime: true,
|
|
26
|
+
/**
|
|
27
|
+
* 视频加载超时,单位秒。
|
|
28
|
+
*/
|
|
29
|
+
loadTimeOut: 10,
|
|
30
|
+
/**
|
|
31
|
+
* 重连次数 -1为一直加载。
|
|
32
|
+
*/
|
|
33
|
+
loadTimeReplay: 3,
|
|
34
|
+
/**
|
|
35
|
+
* MSE模式
|
|
36
|
+
*/
|
|
37
|
+
MSE: false,
|
|
38
|
+
/**
|
|
39
|
+
* WCS模式
|
|
40
|
+
*/
|
|
41
|
+
WCS: false,
|
|
42
|
+
/**
|
|
43
|
+
* WASM模式
|
|
44
|
+
*/
|
|
45
|
+
WASM: false,
|
|
46
|
+
/**
|
|
47
|
+
* WASMSIMD模式
|
|
48
|
+
*/
|
|
49
|
+
WASMSIMD: false,
|
|
50
|
+
/**
|
|
51
|
+
* 硬解码
|
|
52
|
+
*/
|
|
53
|
+
gpuDecoder: false,
|
|
54
|
+
/**
|
|
55
|
+
* 渲染方式
|
|
56
|
+
*/
|
|
57
|
+
webGPU: false,
|
|
58
|
+
/**
|
|
59
|
+
* 渲染容器
|
|
60
|
+
*/
|
|
61
|
+
canvasRender: false,
|
|
62
|
+
/**
|
|
63
|
+
* SRS类型
|
|
64
|
+
*/
|
|
65
|
+
isRtcSRS: false,
|
|
66
|
+
/**
|
|
67
|
+
* ZLM类型
|
|
68
|
+
*/
|
|
69
|
+
isRtcZLM: false,
|
|
70
|
+
/**
|
|
71
|
+
* 裸流
|
|
72
|
+
*/
|
|
73
|
+
isFlow: false,
|
|
74
|
+
/**
|
|
75
|
+
* 水印
|
|
76
|
+
*/
|
|
77
|
+
watermark: {
|
|
78
|
+
text: {
|
|
79
|
+
content: '',
|
|
80
|
+
angle: '',
|
|
81
|
+
color: '',
|
|
82
|
+
fontSize: '',
|
|
83
|
+
opacity: ''
|
|
84
|
+
},
|
|
85
|
+
right: 0,
|
|
86
|
+
top: 0
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* 全屏水印
|
|
90
|
+
*/
|
|
91
|
+
fullWatermark: {
|
|
92
|
+
text: '',
|
|
93
|
+
angle: '',
|
|
94
|
+
color: '',
|
|
95
|
+
fontSize: '',
|
|
96
|
+
opacity: '',
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* 配置清晰
|
|
100
|
+
*/
|
|
101
|
+
quality: ['普清', '高清', '超清', '4K', '8K'],
|
|
102
|
+
/**
|
|
103
|
+
* 默认显示的清晰度,如果不设置,会显示第一个清晰度
|
|
104
|
+
*/
|
|
105
|
+
defaultQuality: null,
|
|
106
|
+
/**
|
|
107
|
+
* PTZ配置
|
|
108
|
+
*/
|
|
109
|
+
ptzConfig: {
|
|
110
|
+
ptz: true,
|
|
111
|
+
ptzMore: true
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* 控制台日志打印
|
|
115
|
+
*/
|
|
116
|
+
debug: false,
|
|
117
|
+
};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { defaultConfig } from "./config";
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
export class EasyPlayer {
|
|
4
|
+
constructor(container, config) {
|
|
5
|
+
this.player = null;
|
|
6
|
+
this.config = {};
|
|
7
|
+
/**
|
|
8
|
+
* 是否销毁
|
|
9
|
+
*/
|
|
10
|
+
this.isDestroy = false;
|
|
11
|
+
/**
|
|
12
|
+
* 播放事件
|
|
13
|
+
*/
|
|
14
|
+
this.onPlay = () => {
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 暂停事件
|
|
18
|
+
*/
|
|
19
|
+
this.onPause = () => {
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 视频信息回调
|
|
23
|
+
*/
|
|
24
|
+
this.onVideoInfo = (videoInfo) => {
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 音频信息回调
|
|
28
|
+
*/
|
|
29
|
+
this.onAudioInfo = (audioInfo) => {
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 全屏事件
|
|
33
|
+
*/
|
|
34
|
+
this.onFullscreen = (isFullscreen) => {
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 音频开关事件
|
|
38
|
+
*/
|
|
39
|
+
this.onMute = (isMute) => {
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 当前网速,单位KB每秒1次
|
|
43
|
+
*/
|
|
44
|
+
this.onKBps = (KBps) => {
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 切换拉伸事件
|
|
48
|
+
*/
|
|
49
|
+
this.onStretch = (isStretch) => {
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* PTZ事件
|
|
53
|
+
*/
|
|
54
|
+
this.onPTZ = (ptz) => {
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* 截图回调
|
|
58
|
+
*/
|
|
59
|
+
this.onScreenshots = () => {
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 右击关闭回调
|
|
63
|
+
*/
|
|
64
|
+
this.onContextmenuClose = () => {
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 视频编码回调
|
|
68
|
+
*/
|
|
69
|
+
this.onDecodeHevc = () => {
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* 直播结束的事件
|
|
73
|
+
*/
|
|
74
|
+
this.onLiveEnd = () => {
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 加载超时事件
|
|
78
|
+
*/
|
|
79
|
+
this.onTimeout = () => {
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 录制结束的事件
|
|
83
|
+
*/
|
|
84
|
+
this.onRecordEnd = () => {
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* 录制开始的事件
|
|
88
|
+
*/
|
|
89
|
+
this.onRecordStart = () => {
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* 清晰度回调
|
|
93
|
+
*/
|
|
94
|
+
this.onQualityChange = (quality) => {
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 录像时间轴跳转回调
|
|
98
|
+
*/
|
|
99
|
+
this.onPlaybackSeek = () => {
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* 录像倍数回调
|
|
103
|
+
*/
|
|
104
|
+
this.onPlaybackRate = () => {
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 播放时间回调
|
|
108
|
+
*/
|
|
109
|
+
this.onTimestamps = () => {
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 播放异常回调
|
|
113
|
+
*/
|
|
114
|
+
this.onError = (err) => {
|
|
115
|
+
};
|
|
116
|
+
this.config = merge({}, defaultConfig, config);
|
|
117
|
+
this.player = new window.EasyPlayerPro(container, this.config);
|
|
118
|
+
this.isDestroy = false;
|
|
119
|
+
this.player.on('play', () => this.onPlay());
|
|
120
|
+
this.player.on('pause', () => this.onPause());
|
|
121
|
+
this.player.on('videoInfo', (videoInfo) => this.onVideoInfo(videoInfo));
|
|
122
|
+
this.player.on('audioInfo', (audioInfo) => this.onAudioInfo(audioInfo));
|
|
123
|
+
this.player.on('fullscreen', (isFullscreen) => this.onFullscreen(isFullscreen));
|
|
124
|
+
this.player.on('mute', (isMute) => this.onMute(isMute));
|
|
125
|
+
this.player.on('kBps', (KBps) => this.onKBps(KBps));
|
|
126
|
+
this.player.on('stretch', (isStretch) => this.onStretch(isStretch));
|
|
127
|
+
this.player.on('ptz', (ptz) => this.onPTZ(ptz));
|
|
128
|
+
this.player.on('screenshots', () => this.onScreenshots());
|
|
129
|
+
this.player.on('contextmenuClose', () => this.onContextmenuClose());
|
|
130
|
+
this.player.on('decodeHevc', () => this.onDecodeHevc());
|
|
131
|
+
this.player.on('liveEnd', () => this.onLiveEnd());
|
|
132
|
+
this.player.on('timeout', () => this.onTimeout());
|
|
133
|
+
this.player.on('recordEnd', () => this.onRecordEnd());
|
|
134
|
+
this.player.on('recordStart', () => this.onRecordStart());
|
|
135
|
+
this.player.on('qualityChange', (quality) => this.onQualityChange(quality));
|
|
136
|
+
this.player.on('playbackSeek', () => this.onPlaybackSeek());
|
|
137
|
+
this.player.on('playbackRate', () => this.onPlaybackRate());
|
|
138
|
+
this.player.on('timestamps', () => this.onTimestamps());
|
|
139
|
+
this.player.on('error', (err) => this.onError(err));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 播放
|
|
143
|
+
* @param url 播放地址
|
|
144
|
+
*/
|
|
145
|
+
play(url) {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
try {
|
|
148
|
+
if (this.player) {
|
|
149
|
+
this.player.play(url).then(resolve).catch(reject);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
reject('player is null');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
reject(err);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 暂停播放
|
|
162
|
+
*/
|
|
163
|
+
pause() {
|
|
164
|
+
this.player && this.player.pause();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 返回是否暂停中状态
|
|
168
|
+
*/
|
|
169
|
+
isPause() {
|
|
170
|
+
if (!this.player)
|
|
171
|
+
return null;
|
|
172
|
+
return this.player.isPause();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 音频切换
|
|
176
|
+
* @param isMute
|
|
177
|
+
*/
|
|
178
|
+
setMute(isMute) {
|
|
179
|
+
this.player && this.player.setMute(isMute);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 是否静音
|
|
183
|
+
*/
|
|
184
|
+
isMute() {
|
|
185
|
+
if (!this.player)
|
|
186
|
+
return null;
|
|
187
|
+
return this.player.isMute();
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* 获取快照
|
|
191
|
+
* @param name 名称(默认时间戳)
|
|
192
|
+
* @param type 类型(png|jpg,默认png)
|
|
193
|
+
* @param rato 压缩了(0-1,默认0.92)
|
|
194
|
+
* @param format 数据格式(download,base64,blob,默认download)
|
|
195
|
+
*/
|
|
196
|
+
screenshot(name, type, rato, format) {
|
|
197
|
+
if (!this.player)
|
|
198
|
+
return null;
|
|
199
|
+
return this.player.screenshot(name, type, rato, format);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 全屏(取消全屏)播放视频
|
|
203
|
+
* @param isFullscreen 是否全屏
|
|
204
|
+
*/
|
|
205
|
+
setFullscreen(isFullscreen) {
|
|
206
|
+
this.player && this.player.setFullscreen(isFullscreen);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 推出全屏
|
|
210
|
+
*/
|
|
211
|
+
exitFullscreen() {
|
|
212
|
+
this.player && this.player.exitFullscreen();
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 设置分辨率,分辨率必须是quality里面的数据
|
|
216
|
+
* @param quality
|
|
217
|
+
*/
|
|
218
|
+
setQuality(quality) {
|
|
219
|
+
this.player && this.player.setQuality(quality);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* 设置录像倍数
|
|
223
|
+
* @param rate
|
|
224
|
+
*/
|
|
225
|
+
setRate(rate) {
|
|
226
|
+
this.player && this.player.setRate(rate);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* 设置录像跳转时间(s)
|
|
230
|
+
*/
|
|
231
|
+
seekTime(time) {
|
|
232
|
+
this.player && this.player.seekTime(time);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 获取视频信息
|
|
236
|
+
*/
|
|
237
|
+
getVideoInfo() {
|
|
238
|
+
if (!this.player)
|
|
239
|
+
return null;
|
|
240
|
+
return this.player.getVideoInfo();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 获取音频信息
|
|
244
|
+
*/
|
|
245
|
+
getAudioInfo() {
|
|
246
|
+
if (!this.player)
|
|
247
|
+
return null;
|
|
248
|
+
return this.player.getAudioInfo();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 设置语音对讲状态(PTZ需开启)
|
|
252
|
+
* @param isMic
|
|
253
|
+
*/
|
|
254
|
+
setMic(isMic) {
|
|
255
|
+
this.player && this.player.setMic(isMic);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* 关闭视频,释放底层资源
|
|
259
|
+
*/
|
|
260
|
+
destroy() {
|
|
261
|
+
this.player && this.player.destroy();
|
|
262
|
+
this.player = null;
|
|
263
|
+
this.isDestroy = true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { defaultConfig } from "./config";
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
export class EasyPlayer {
|
|
4
|
+
constructor(container, config) {
|
|
5
|
+
this.player = null;
|
|
6
|
+
this.config = {};
|
|
7
|
+
/**
|
|
8
|
+
* 是否销毁
|
|
9
|
+
*/
|
|
10
|
+
this.isDestroy = false;
|
|
11
|
+
/**
|
|
12
|
+
* 播放事件
|
|
13
|
+
*/
|
|
14
|
+
this.onPlay = () => {
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 暂停事件
|
|
18
|
+
*/
|
|
19
|
+
this.onPause = () => {
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 视频信息回调
|
|
23
|
+
*/
|
|
24
|
+
this.onVideoInfo = (videoInfo) => {
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 音频信息回调
|
|
28
|
+
*/
|
|
29
|
+
this.onAudioInfo = (audioInfo) => {
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 全屏事件
|
|
33
|
+
*/
|
|
34
|
+
this.onFullscreen = (isFullscreen) => {
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 音频开关事件
|
|
38
|
+
*/
|
|
39
|
+
this.onMute = (isMute) => {
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 当前网速,单位KB每秒1次
|
|
43
|
+
*/
|
|
44
|
+
this.onKBps = (KBps) => {
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 切换拉伸事件
|
|
48
|
+
*/
|
|
49
|
+
this.onStretch = (isStretch) => {
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* PTZ事件
|
|
53
|
+
*/
|
|
54
|
+
this.onPTZ = (ptz) => {
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* 截图回调
|
|
58
|
+
*/
|
|
59
|
+
this.onScreenshots = () => {
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 右击关闭回调
|
|
63
|
+
*/
|
|
64
|
+
this.onContextmenuClose = () => {
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 视频编码回调
|
|
68
|
+
*/
|
|
69
|
+
this.onDecodeHevc = () => {
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* 直播结束的事件
|
|
73
|
+
*/
|
|
74
|
+
this.onLiveEnd = () => {
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 加载超时事件
|
|
78
|
+
*/
|
|
79
|
+
this.onTimeout = () => {
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 录制结束的事件
|
|
83
|
+
*/
|
|
84
|
+
this.onRecordEnd = () => {
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* 录制开始的事件
|
|
88
|
+
*/
|
|
89
|
+
this.onRecordStart = () => {
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* 清晰度回调
|
|
93
|
+
*/
|
|
94
|
+
this.onQualityChange = (quality) => {
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 录像时间轴跳转回调
|
|
98
|
+
*/
|
|
99
|
+
this.onPlaybackSeek = () => {
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* 录像倍数回调
|
|
103
|
+
*/
|
|
104
|
+
this.onPlaybackRate = () => {
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 播放时间回调
|
|
108
|
+
*/
|
|
109
|
+
this.onTimestamps = () => {
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 播放异常回调
|
|
113
|
+
*/
|
|
114
|
+
this.onError = (err) => {
|
|
115
|
+
};
|
|
116
|
+
this.config = merge({}, defaultConfig, config);
|
|
117
|
+
this.player = new window.EasyPlayerPro(container, this.config);
|
|
118
|
+
this.isDestroy = false;
|
|
119
|
+
this.player.on('play', () => this.onPlay());
|
|
120
|
+
this.player.on('pause', () => this.onPause());
|
|
121
|
+
this.player.on('videoInfo', (videoInfo) => this.onVideoInfo(videoInfo));
|
|
122
|
+
this.player.on('audioInfo', (audioInfo) => this.onAudioInfo(audioInfo));
|
|
123
|
+
this.player.on('fullscreen', (isFullscreen) => this.onFullscreen(isFullscreen));
|
|
124
|
+
this.player.on('mute', (isMute) => this.onMute(isMute));
|
|
125
|
+
this.player.on('kBps', (KBps) => this.onKBps(KBps));
|
|
126
|
+
this.player.on('stretch', (isStretch) => this.onStretch(isStretch));
|
|
127
|
+
this.player.on('ptz', (ptz) => this.onPTZ(ptz));
|
|
128
|
+
this.player.on('screenshots', () => this.onScreenshots());
|
|
129
|
+
this.player.on('contextmenuClose', () => this.onContextmenuClose());
|
|
130
|
+
this.player.on('decodeHevc', () => this.onDecodeHevc());
|
|
131
|
+
this.player.on('liveEnd', () => this.onLiveEnd());
|
|
132
|
+
this.player.on('timeout', () => this.onTimeout());
|
|
133
|
+
this.player.on('recordEnd', () => this.onRecordEnd());
|
|
134
|
+
this.player.on('recordStart', () => this.onRecordStart());
|
|
135
|
+
this.player.on('qualityChange', (quality) => this.onQualityChange(quality));
|
|
136
|
+
this.player.on('playbackSeek', () => this.onPlaybackSeek());
|
|
137
|
+
this.player.on('playbackRate', () => this.onPlaybackRate());
|
|
138
|
+
this.player.on('timestamps', () => this.onTimestamps());
|
|
139
|
+
this.player.on('error', (err) => this.onError(err));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 播放
|
|
143
|
+
* @param url 播放地址
|
|
144
|
+
*/
|
|
145
|
+
play(url) {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
try {
|
|
148
|
+
if (this.player) {
|
|
149
|
+
this.player.play(url).then(resolve).catch(reject);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
reject('player is null');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
reject(err);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 暂停播放
|
|
162
|
+
*/
|
|
163
|
+
pause() {
|
|
164
|
+
this.player && this.player.pause();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 返回是否暂停中状态
|
|
168
|
+
*/
|
|
169
|
+
isPause() {
|
|
170
|
+
if (!this.player)
|
|
171
|
+
return null;
|
|
172
|
+
return this.player.isPause();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 音频切换
|
|
176
|
+
* @param isMute
|
|
177
|
+
*/
|
|
178
|
+
setMute(isMute) {
|
|
179
|
+
this.player && this.player.setMute(isMute);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 是否静音
|
|
183
|
+
*/
|
|
184
|
+
isMute() {
|
|
185
|
+
if (!this.player)
|
|
186
|
+
return null;
|
|
187
|
+
return this.player.isMute();
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* 获取快照
|
|
191
|
+
* @param name 名称(默认时间戳)
|
|
192
|
+
* @param type 类型(png|jpg,默认png)
|
|
193
|
+
* @param rato 压缩了(0-1,默认0.92)
|
|
194
|
+
* @param format 数据格式(download,base64,blob,默认download)
|
|
195
|
+
*/
|
|
196
|
+
screenshot(name, type, rato, format) {
|
|
197
|
+
if (!this.player)
|
|
198
|
+
return null;
|
|
199
|
+
return this.player.screenshot(name, type, rato, format);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 全屏(取消全屏)播放视频
|
|
203
|
+
* @param isFullscreen 是否全屏
|
|
204
|
+
*/
|
|
205
|
+
setFullscreen(isFullscreen) {
|
|
206
|
+
this.player && this.player.setFullscreen(isFullscreen);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 推出全屏
|
|
210
|
+
*/
|
|
211
|
+
exitFullscreen() {
|
|
212
|
+
this.player && this.player.exitFullscreen();
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 设置分辨率,分辨率必须是quality里面的数据
|
|
216
|
+
* @param quality
|
|
217
|
+
*/
|
|
218
|
+
setQuality(quality) {
|
|
219
|
+
this.player && this.player.setQuality(quality);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* 设置录像倍数
|
|
223
|
+
* @param rate
|
|
224
|
+
*/
|
|
225
|
+
setRate(rate) {
|
|
226
|
+
this.player && this.player.setRate(rate);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* 设置录像跳转时间(s)
|
|
230
|
+
*/
|
|
231
|
+
seekTime(time) {
|
|
232
|
+
this.player && this.player.seekTime(time);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 获取视频信息
|
|
236
|
+
*/
|
|
237
|
+
getVideoInfo() {
|
|
238
|
+
if (!this.player)
|
|
239
|
+
return null;
|
|
240
|
+
return this.player.getVideoInfo();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 获取音频信息
|
|
244
|
+
*/
|
|
245
|
+
getAudioInfo() {
|
|
246
|
+
if (!this.player)
|
|
247
|
+
return null;
|
|
248
|
+
return this.player.getAudioInfo();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 设置语音对讲状态(PTZ需开启)
|
|
252
|
+
* @param isMic
|
|
253
|
+
*/
|
|
254
|
+
setMic(isMic) {
|
|
255
|
+
this.player && this.player.setMic(isMic);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* 关闭视频,释放底层资源
|
|
259
|
+
*/
|
|
260
|
+
destroy() {
|
|
261
|
+
this.player && this.player.destroy();
|
|
262
|
+
this.player = null;
|
|
263
|
+
this.isDestroy = true;
|
|
264
|
+
}
|
|
265
|
+
}
|
package/lib/index.js
ADDED