easy-player-pro 0.1.10 → 0.1.12

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.
@@ -120,6 +120,7 @@ export class EasyPlayerPro {
120
120
  }
121
121
  });
122
122
  this.container = container;
123
+ //@ts-ignore
123
124
  this.player = new window.EasyPlayerPro(this.container, this.config);
124
125
  this.videoElement = this.player.$container.querySelector('video');
125
126
  this.isDestroy = false;
@@ -350,6 +351,45 @@ export class EasyPlayerPro {
350
351
  setQuality(quality) {
351
352
  this.player && this.player.setQuality(quality);
352
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
+ }
353
393
  /**
354
394
  * 设置录像倍数
355
395
  * @param rate
@@ -412,6 +452,7 @@ export class EasyPlayerPro {
412
452
  }
413
453
  close() {
414
454
  this.destroy();
455
+ //@ts-ignore
415
456
  this.player = new window.EasyPlayerPro(this.container, this.config);
416
457
  }
417
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: (qualityList: string[], 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.10",
3
+ "version": "0.1.12",
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",