@eluvio/elv-player-js 1.0.91 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +19 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-player-js",
3
- "version": "1.0.91",
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",
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
 
@@ -627,7 +640,9 @@ export class EluvioPlayer {
627
640
  this.Destroy();
628
641
  }
629
642
  } catch (error) {
630
- this.playerOptions.errorCallback(error);
643
+ if(this.playerOptions.errorCallback) {
644
+ this.playerOptions.errorCallback(error, this);
645
+ }
631
646
 
632
647
  if(error.status === 500) {
633
648
  this.HardReload(error, 10000);