@eluvio/elv-player-js 1.0.90 → 1.0.92

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-player-js",
3
- "version": "1.0.90",
3
+ "version": "1.0.92",
4
4
  "description": "![Eluvio Logo](src/static/images/Logo.png \"Eluvio Logo\")",
5
5
  "main": "src/index.js",
6
6
  "license": "MIT",
@@ -108,7 +108,7 @@ const Time = (time, total) => {
108
108
  };
109
109
 
110
110
  class PlayerControls {
111
- constructor(target, video, playerOptions, posterUrl, className) {
111
+ constructor({target, video, playerOptions, posterUrl, className}) {
112
112
  this.target = target;
113
113
  this.video = video;
114
114
  this.playerOptions = playerOptions;
package/src/index.js CHANGED
@@ -119,7 +119,8 @@ const DefaultParameters = {
119
119
  dashjsOptions: undefined,
120
120
  // eslint-disable-next-line no-unused-vars
121
121
  playerCallback: ({player, videoElement, hlsPlayer, dashPlayer, posterUrl}) => {},
122
- errorCallback: (error) => {
122
+ // eslint-disable-next-line no-unused-vars
123
+ errorCallback: (error, player) => {
123
124
  // eslint-disable-next-line no-console
124
125
  console.error("ELUVIO PLAYER: Error");
125
126
  // eslint-disable-next-line no-console
@@ -333,9 +334,21 @@ export class EluvioPlayer {
333
334
  }
334
335
 
335
336
  let availableDRMs = (await client.AvailableDRMs()).filter(drm => (this.sourceOptions.drms || []).includes(drm));
337
+ let availableProtocols = this.sourceOptions.protocols;
338
+
339
+ let protocol, drm;
340
+ while(!(protocol && drm)) {
341
+ protocol = availableProtocols.find(protocol => this.sourceOptions.playoutOptions[protocol]);
342
+ drm = this.sourceOptions.drms.find(drm => availableDRMs.includes(drm) && this.sourceOptions.playoutOptions[protocol].playoutMethods[drm]);
336
343
 
337
- const protocol = this.sourceOptions.protocols.find(protocol => this.sourceOptions.playoutOptions[protocol]);
338
- const drm = this.sourceOptions.drms.find(drm => availableDRMs.includes(drm) && this.sourceOptions.playoutOptions[protocol].playoutMethods[drm]);
344
+ if(!drm) {
345
+ availableProtocols = availableProtocols.filter(p => p !== protocol);
346
+
347
+ if(availableProtocols.length === 0) {
348
+ throw Error("No valid protocol / DRM combination available");
349
+ }
350
+ }
351
+ }
339
352
 
340
353
  const { playoutUrl, drms } = this.sourceOptions.playoutOptions[protocol].playoutMethods[drm];
341
354
 
@@ -577,7 +590,13 @@ export class EluvioPlayer {
577
590
  }
578
591
  }
579
592
 
580
- this.controls = new PlayerControls(this.target, this.video, this.playerOptions, this.playerOptions.controlsClassName);
593
+ this.controls = new PlayerControls({
594
+ target: this.target,
595
+ video: this.video,
596
+ playerOptions: this.playerOptions,
597
+ className: this.playerOptions.controlsClassName
598
+ });
599
+
581
600
  this.PosterUrl().then(posterUrl => this.controls.SetPosterUrl(posterUrl));
582
601
 
583
602
  multiviewOptions.target = this.target;
@@ -621,7 +640,9 @@ export class EluvioPlayer {
621
640
  this.Destroy();
622
641
  }
623
642
  } catch (error) {
624
- this.playerOptions.errorCallback(error);
643
+ if(this.playerOptions.errorCallback) {
644
+ this.playerOptions.errorCallback(error, this);
645
+ }
625
646
 
626
647
  if(error.status === 500) {
627
648
  this.HardReload(error, 10000);