@eluvio/elv-player-js 1.0.91 → 1.0.93

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 +35 -5
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.93",
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);
@@ -794,10 +809,15 @@ export class EluvioPlayer {
794
809
  const DashPlayer = (await import("dashjs")).default;
795
810
  const dashPlayer = DashPlayer.MediaPlayer().create();
796
811
 
812
+ dashPlayer.updateSettings({
813
+ "streaming": {
814
+ "fastSwitchEnabled": true
815
+ }
816
+ });
817
+
797
818
  if(this.playerOptions.capLevelToPlayerSize) {
798
819
  dashPlayer.updateSettings({
799
820
  "streaming": {
800
- "fastSwitchEnabled": true,
801
821
  "abr": {
802
822
  "limitBitrateByPortal": true
803
823
  }
@@ -908,6 +928,16 @@ export class EluvioPlayer {
908
928
  this.UpdateTextTracks({dashPlayer});
909
929
  });
910
930
 
931
+ // DashJS doesn't automatically handle video track change - Add event listener to handle it
932
+ this.video.textTracks.addEventListener("change", () => {
933
+ const dashTracks = dashPlayer.getTracksFor("text");
934
+ const activeTrack = Array.from(this.video.textTracks).find(track => track.mode === "showing");
935
+
936
+ dashPlayer.setTextTrack(
937
+ !activeTrack ? -1 : dashTracks.findIndex(dashTrack => dashTrack.lang === activeTrack.language || (dashTrack.index || "").toString() === (activeTrack.label || "").toString())
938
+ );
939
+ });
940
+
911
941
  this.player = dashPlayer;
912
942
  this.dashPlayer = dashPlayer;
913
943
  }