easy-player-pro 0.1.8 → 0.1.10
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultConfig } from "./config";
|
|
2
|
-
import {
|
|
2
|
+
import { mergeWith } from 'lodash-es';
|
|
3
3
|
export class EasyPlayerPro {
|
|
4
4
|
constructor(container, config) {
|
|
5
5
|
this.player = null;
|
|
@@ -114,8 +114,13 @@ export class EasyPlayerPro {
|
|
|
114
114
|
*/
|
|
115
115
|
this.onError = (err) => {
|
|
116
116
|
};
|
|
117
|
-
this.config =
|
|
118
|
-
|
|
117
|
+
this.config = mergeWith({}, defaultConfig, config, (objValue, srcValue) => {
|
|
118
|
+
if (Array.isArray(objValue)) {
|
|
119
|
+
return srcValue;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
this.container = container;
|
|
123
|
+
this.player = new window.EasyPlayerPro(this.container, this.config);
|
|
119
124
|
this.videoElement = this.player.$container.querySelector('video');
|
|
120
125
|
this.isDestroy = false;
|
|
121
126
|
this.controller = new AbortController();
|
|
@@ -391,13 +396,22 @@ export class EasyPlayerPro {
|
|
|
391
396
|
* 关闭视频,释放底层资源
|
|
392
397
|
*/
|
|
393
398
|
destroy() {
|
|
394
|
-
|
|
395
|
-
if (this.
|
|
396
|
-
this.
|
|
399
|
+
try {
|
|
400
|
+
if (this.player) {
|
|
401
|
+
if (this._isRtcSRS()) {
|
|
402
|
+
this.controller.abort();
|
|
403
|
+
}
|
|
404
|
+
this.player.destroy().catch(() => { });
|
|
397
405
|
}
|
|
398
|
-
this.player
|
|
406
|
+
this.player = null;
|
|
407
|
+
this.container.innerHTML = '';
|
|
408
|
+
this.container.removeAttribute('data--easy-prov');
|
|
409
|
+
this.isDestroy = true;
|
|
399
410
|
}
|
|
400
|
-
|
|
401
|
-
|
|
411
|
+
catch (error) { }
|
|
412
|
+
}
|
|
413
|
+
close() {
|
|
414
|
+
this.destroy();
|
|
415
|
+
this.player = new window.EasyPlayerPro(this.container, this.config);
|
|
402
416
|
}
|
|
403
417
|
}
|
|
@@ -15,6 +15,7 @@ export type AudioInfoType = {
|
|
|
15
15
|
export declare class EasyPlayerPro {
|
|
16
16
|
private player;
|
|
17
17
|
private config;
|
|
18
|
+
private container;
|
|
18
19
|
private _url;
|
|
19
20
|
private videoElement;
|
|
20
21
|
private controller;
|
|
@@ -188,6 +189,7 @@ export declare class EasyPlayerPro {
|
|
|
188
189
|
* 关闭视频,释放底层资源
|
|
189
190
|
*/
|
|
190
191
|
destroy(): void;
|
|
192
|
+
close(): void;
|
|
191
193
|
}
|
|
192
194
|
export interface EasyPlayerProType {
|
|
193
195
|
isDestroy: boolean;
|
|
@@ -227,4 +229,5 @@ export interface EasyPlayerProType {
|
|
|
227
229
|
getAudioInfo: () => AudioInfoType | null;
|
|
228
230
|
setMic: (isMic: boolean) => void;
|
|
229
231
|
destroy: () => void;
|
|
232
|
+
close: () => void;
|
|
230
233
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-player-pro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "easy-player-pro 是一款能够同时支持HTTP、HTTP-FLV、HLS(m3u8)、WS、WEBRTC、FMP4视频直播与视频点播等多种协议,支持H.264、H.265、AAC、G711A、Mp3等多种音视频编码格式,支持MSE、WASM、WebCodec等多种解码方式,支持Windows、Linux、Android、iOS全平台终端的H5播放器,使用简单, 功能强大",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./lib/index.js",
|