@eluvio/elv-player-js 1.0.94 → 1.0.96

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.94",
3
+ "version": "1.0.96",
4
4
  "description": "![Eluvio Logo](src/static/images/Logo.png \"Eluvio Logo\")",
5
5
  "main": "src/index.js",
6
6
  "license": "MIT",
@@ -4,6 +4,7 @@ import PauseIcon from "./static/icons/media/Pause icon.svg";
4
4
  import FullscreenIcon from "./static/icons/media/Full Screen icon.svg";
5
5
  import ExitFullscreenIcon from "./static/icons/minimize.svg";
6
6
  import SettingsIcon from "./static/icons/media/Settings icon.svg";
7
+ import CloseIcon from "./static/icons/x.svg";
7
8
  import MutedIcon from "./static/icons/media/no volume icon.svg";
8
9
  import VolumeLowIcon from "./static/icons/media/low volume icon.svg";
9
10
  import VolumeHighIcon from "./static/icons/media/Volume icon.svg";
@@ -675,6 +676,21 @@ class PlayerControls {
675
676
  }
676
677
  }
677
678
 
679
+ InitializeMenu(mode) {
680
+ this.settingsMenu.innerHTML = "";
681
+ this.settingsMenu.classList.remove("eluvio-player__controls__settings-menu-hidden");
682
+ this.settingsMenu.setAttribute("data-mode", mode);
683
+
684
+ const closeButton = CreateImageButton({
685
+ parent: this.settingsMenu,
686
+ svg: CloseIcon,
687
+ type: "button",
688
+ classes: ["eluvio-player__controls__settings-menu__close"]
689
+ });
690
+
691
+ closeButton.addEventListener("click", () => this.HideSettingsMenu());
692
+ }
693
+
678
694
  AddSetting({Retrieve, Set}) {
679
695
  if(!Retrieve) { return; }
680
696
 
@@ -692,8 +708,7 @@ class PlayerControls {
692
708
 
693
709
  if(Set) {
694
710
  optionSelectionButton.addEventListener("click", () => {
695
- this.settingsMenu.innerHTML = "";
696
- this.settingsMenu.setAttribute("data-mode", "settings-submenu");
711
+ this.InitializeMenu("settings-submenu");
697
712
 
698
713
  const backButton = CreateElement({
699
714
  parent: this.settingsMenu,
@@ -703,11 +718,12 @@ class PlayerControls {
703
718
 
704
719
  CreateElement({
705
720
  parent: backButton,
706
- type: "svg"
721
+ classes: ["eluvio-player__controls__settings-menu__option-back__icon"]
707
722
  }).innerHTML = LeftArrow;
708
723
 
709
724
  CreateElement({
710
725
  parent: backButton,
726
+ classes: ["eluvio-player__controls__settings-menu__option-back__text"]
711
727
  }).innerHTML = label;
712
728
 
713
729
  backButton.addEventListener("click", () => this.ShowSettingsMenu());
@@ -738,9 +754,7 @@ class PlayerControls {
738
754
  }
739
755
 
740
756
  ShowSettingsMenu() {
741
- this.settingsMenu.innerHTML = "";
742
- this.settingsMenu.classList.remove("eluvio-player__controls__settings-menu-hidden");
743
- this.settingsMenu.setAttribute("data-mode", "settings");
757
+ this.InitializeMenu("settings");
744
758
 
745
759
  if(this.GetLevels) {
746
760
  this.AddSetting({Retrieve: this.GetLevels, Set: this.SetLevel});
package/src/index.js CHANGED
@@ -582,14 +582,6 @@ export class EluvioPlayer {
582
582
 
583
583
  let { protocol, drm, playoutUrl, drms, multiviewOptions } = await playoutOptionsPromise;
584
584
 
585
- if(["fairplay", "sample-aes"].includes(drm)) {
586
- // Switch to default controls if using fairplay or sample aes
587
- if(this.playerOptions.controls !== EluvioPlayerParameters.controls.OFF) {
588
- this.playerOptions.controls = EluvioPlayerParameters.controls.DEFAULT;
589
- this.video.controls = true;
590
- }
591
- }
592
-
593
585
  this.controls = new PlayerControls({
594
586
  target: this.target,
595
587
  video: this.video,
@@ -653,20 +645,59 @@ export class EluvioPlayer {
653
645
  async InitializeHLS({playoutUrl, authorizationToken, drm, multiviewOptions}) {
654
646
  const HLSPlayer = (await import("hls-fix")).default;
655
647
 
656
- if(drm === "fairplay") {
657
- InitializeFairPlayStream({playoutOptions: this.sourceOptions.playoutOptions, video: this.video});
648
+ if(["fairplay", "sample-aes"].includes(drm) || !HLSPlayer.isSupported()) {
649
+ // HLS JS NOT SUPPORTED - Handle native player
658
650
 
659
- if(multiviewOptions.enabled) {
660
- this.controls.InitializeMultiViewControls(multiviewOptions);
651
+ if(drm === "fairplay") {
652
+ InitializeFairPlayStream({playoutOptions: this.sourceOptions.playoutOptions, video: this.video});
653
+ } else {
654
+ this.video.src = playoutUrl.toString();
661
655
  }
662
- this.UpdateTextTracks();
663
- } else if(!HLSPlayer.isSupported() || drm === "sample-aes") {
664
- this.video.src = playoutUrl.toString();
665
656
 
666
657
  if(multiviewOptions.enabled) {
667
- this.controls.InitializeMultiViewControls(multiviewOptions);
658
+ const Switch = multiviewOptions.SwitchView;
659
+
660
+ multiviewOptions.SwitchView = async (view) => {
661
+ await Switch(view);
662
+ };
663
+
664
+ if(this.controls) {
665
+ this.controls.InitializeMultiViewControls(multiviewOptions);
666
+ }
667
+ }
668
+
669
+ const UpdateAudioTracks = () => {
670
+ if(!this.video.audioTracks || this.video.audioTracks.length <= 1) { return; }
671
+
672
+ this.controls.SetAudioTrackControls({
673
+ GetAudioTracks: () => {
674
+ const tracks = Array.from(this.video.audioTracks).map(track => ({
675
+ index: track.id,
676
+ label: track.label || track.language,
677
+ active: track.enabled,
678
+ activeLabel: `Audio: ${track.label || track.language}`
679
+ }));
680
+
681
+ return {label: "Audio Track", options: tracks};
682
+ },
683
+ SetAudioTrack: index => {
684
+ Array.from(this.video.audioTracks).forEach(track =>
685
+ track.enabled = index.toString() === track.id
686
+ );
687
+ }
688
+ });
689
+ };
690
+
691
+ // Set up audio and subtitle tracks
692
+ if(this.controls) {
693
+ this.video.textTracks.addEventListener("addtrack", this.UpdateTextTracks());
694
+ this.video.textTracks.addEventListener("removetrack", this.UpdateTextTracks());
695
+ this.video.audioTracks.addEventListener("addtrack", UpdateAudioTracks);
696
+ this.video.audioTracks.addEventListener("removetrack", UpdateAudioTracks);
668
697
  }
669
698
  } else {
699
+ // HLS JS
700
+
670
701
  playoutUrl.removeQuery("authorization");
671
702
 
672
703
  // Inject
@@ -689,7 +720,7 @@ export class EluvioPlayer {
689
720
  hlsPlayer.loadSource(playoutUrl.toString());
690
721
  hlsPlayer.attachMedia(this.video);
691
722
 
692
- if(multiviewOptions.enabled) {
723
+ if(this.controls && multiviewOptions.enabled) {
693
724
  const Switch = multiviewOptions.SwitchView;
694
725
 
695
726
  multiviewOptions.SwitchView = async (view) => {
@@ -854,7 +885,7 @@ export class EluvioPlayer {
854
885
  this.playerOptions.autoplay === EluvioPlayerParameters.autoplay.ON
855
886
  );
856
887
 
857
- if(multiviewOptions.enabled) {
888
+ if(this.controls && multiviewOptions.enabled) {
858
889
  this.controls.InitializeMultiViewControls(multiviewOptions);
859
890
  }
860
891
 
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
@@ -139,7 +139,7 @@ $button-height: 35px;
139
139
 
140
140
  &__video {
141
141
  background: $background-color;
142
- height: 100%;
142
+ height: auto;
143
143
  margin: auto;
144
144
  object-fit: contain;
145
145
  object-position: center;
@@ -345,6 +345,7 @@ $button-height: 35px;
345
345
  }
346
346
 
347
347
  &__settings-menu {
348
+ backdrop-filter: blur(5px);
348
349
  background: $menu-color;
349
350
  border-radius: 3px;
350
351
  bottom: 45px;
@@ -363,6 +364,22 @@ $button-height: 35px;
363
364
 
364
365
  button {
365
366
  border: 1px solid transparent;
367
+
368
+ &.eluvio-player__controls__settings-menu__close {
369
+ border: 1.5px solid $button-color;
370
+ border-radius: 100%;
371
+ }
372
+ }
373
+
374
+ &__close {
375
+ display: none;
376
+ position: absolute;
377
+ right: 20px;
378
+ top: 20px;
379
+
380
+ * {
381
+ color: $button-color;
382
+ }
366
383
  }
367
384
 
368
385
  &__option {
@@ -378,28 +395,37 @@ $button-height: 35px;
378
395
  width: 100%;
379
396
 
380
397
  &-back {
398
+ align-items: center;
381
399
  display: flex;
382
- font-weight: 500;
400
+ position: relative;
383
401
  width: 100%;
402
+ }
384
403
 
385
- svg {
386
- height: 15px;
387
- margin-right: 5px;
388
- width: 15px;
389
- }
404
+ &-back__icon {
405
+ height: 15px;
406
+ left: 20px;
407
+ margin-right: 5px;
408
+ position: absolute;
409
+ width: 15px;
390
410
 
391
- div {
411
+ svg {
412
+ height: 100%;
392
413
  width: 100%;
393
414
  }
394
415
  }
395
416
 
417
+ &-back__text {
418
+ padding-inline: 25px;
419
+ width: 100%;
420
+ }
421
+
396
422
  &-selected {
397
- color: $button-color;
423
+ color: $white;
398
424
  }
399
425
 
400
426
  &:hover {
401
427
  background: $menu-active-color;
402
- color: $button-color;
428
+ color: $white;
403
429
  }
404
430
 
405
431
  &.focus-visible {
@@ -668,11 +694,28 @@ $button-height: 35px;
668
694
  }
669
695
 
670
696
  .eluvio-player__controls__settings-menu {
697
+ align-items: center;
671
698
  height: 100%;
672
- padding: 20px 0;
699
+ max-height: 100%;
700
+ padding: 80px 0 30px;
673
701
  right: 0;
674
702
  top: 0;
675
703
  width: 100%;
704
+
705
+ &__option {
706
+ font-size: 20px;
707
+ margin-bottom: 5px;
708
+ text-align: center;
709
+
710
+ &-back {
711
+ font-size: 24px;
712
+ margin-bottom: 20px;
713
+ }
714
+ }
715
+
716
+ &__close {
717
+ display: unset;
718
+ }
676
719
  }
677
720
 
678
721
  .eluvio-player__hotspot-overlay {