easy-player-pro 0.1.9 → 0.1.11

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 { merge } from 'lodash-es';
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 = merge({}, defaultConfig, config);
117
+ this.config = mergeWith({}, defaultConfig, config, (objValue, srcValue) => {
118
+ if (Array.isArray(objValue)) {
119
+ return srcValue;
120
+ }
121
+ });
118
122
  this.container = container;
123
+ //@ts-ignore
119
124
  this.player = new window.EasyPlayerPro(this.container, this.config);
120
125
  this.videoElement = this.player.$container.querySelector('video');
121
126
  this.isDestroy = false;
@@ -346,6 +351,45 @@ export class EasyPlayerPro {
346
351
  setQuality(quality) {
347
352
  this.player && this.player.setQuality(quality);
348
353
  }
354
+ /**
355
+ * 设置分辨率列表
356
+ * @param qualityList
357
+ * @param quality
358
+ */
359
+ setQualityList(qualityList, quality) {
360
+ const _quality = quality || qualityList[0];
361
+ const easyPlayerQualityMenu = this.player.$container.querySelector('.easyplayer-quality-menu');
362
+ if (easyPlayerQualityMenu) {
363
+ const easyPlayerQualityIconText = easyPlayerQualityMenu.querySelector('.easyplayer-quality-icon-text');
364
+ const easyPlayerQualityMenuList = easyPlayerQualityMenu.querySelector('.easyplayer-quality-menu-list');
365
+ if (qualityList.length > 0) {
366
+ if (easyPlayerQualityIconText) {
367
+ easyPlayerQualityIconText.innerText = _quality;
368
+ this.setQuality(_quality);
369
+ }
370
+ if (easyPlayerQualityMenuList) {
371
+ easyPlayerQualityMenuList.innerHTML = '';
372
+ easyPlayerQualityMenuList.append(...qualityList.map(c => {
373
+ const item = document.createElement('div');
374
+ item.innerText = c;
375
+ item.setAttribute('data-quality', c);
376
+ item.classList.add('easyplayer-quality-menu-item');
377
+ if (c === _quality) {
378
+ item.classList.add('easyplayer-quality-menu-item-active');
379
+ }
380
+ item.addEventListener('click', (event) => {
381
+ easyPlayerQualityMenuList.querySelectorAll('.easyplayer-quality-menu-item').forEach((c) => {
382
+ c.classList.remove('easyplayer-quality-menu-item-active');
383
+ });
384
+ //@ts-ignore
385
+ event.currentTarget && event.currentTarget.classList.add('easyplayer-quality-menu-item-active');
386
+ });
387
+ return item;
388
+ }));
389
+ }
390
+ }
391
+ }
392
+ }
349
393
  /**
350
394
  * 设置录像倍数
351
395
  * @param rate
@@ -408,6 +452,7 @@ export class EasyPlayerPro {
408
452
  }
409
453
  close() {
410
454
  this.destroy();
455
+ //@ts-ignore
411
456
  this.player = new window.EasyPlayerPro(this.container, this.config);
412
457
  }
413
458
  }
@@ -159,6 +159,12 @@ export declare class EasyPlayerPro {
159
159
  * @param quality
160
160
  */
161
161
  setQuality(quality: string): void;
162
+ /**
163
+ * 设置分辨率列表
164
+ * @param qualityList
165
+ * @param quality
166
+ */
167
+ setQualityList(qualityList: string[], quality?: string): void;
162
168
  /**
163
169
  * 设置录像倍数
164
170
  * @param rate
@@ -223,6 +229,7 @@ export interface EasyPlayerProType {
223
229
  setFullscreen: (isFullscreen: boolean) => void;
224
230
  exitFullscreen: () => void;
225
231
  setQuality: (quality: string) => void;
232
+ setQualityList: (quality: string[]) => void;
226
233
  setRate: (rate: number) => void;
227
234
  seekTime: (time: number) => void;
228
235
  getVideoInfo: () => VideoInfoType | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-player-pro",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
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",