@eluvio/elv-player-js 1.0.122 → 1.0.124
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/dist/0.bundle.js +10 -0
- package/dist/3.bundle.js +18 -0
- package/dist/4.bundle.js +1 -0
- package/dist/5.bundle.js +1 -0
- package/dist/6.bundle.js +289 -0
- package/dist/82039b3023d7b2c52c275b57ce7bbc42.png +0 -0
- package/dist/index.js +1 -0
- package/dist/vendors~main.bundle.js +39 -0
- package/package.json +1 -1
- package/src/PlayerControls.js +16 -0
- package/src/index.js +65 -8
- package/src/static/stylesheets/player.scss +3 -1
package/src/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import ResizeObserver from "resize-observer-polyfill";
|
|
|
11
11
|
import {InitializeFairPlayStream} from "./FairPlay";
|
|
12
12
|
import PlayerControls, {CreateElement, InitializeTicketPrompt, PlayPause} from "./PlayerControls";
|
|
13
13
|
|
|
14
|
+
import {Utils} from "@eluvio/elv-client-js";
|
|
15
|
+
|
|
14
16
|
export const EluvioPlayerParameters = {
|
|
15
17
|
networks: {
|
|
16
18
|
MAIN: "https://main.net955305.contentfabric.io/config",
|
|
@@ -18,6 +20,10 @@ export const EluvioPlayerParameters = {
|
|
|
18
20
|
TEST: "https://test.net955203.contentfabric.io/config",
|
|
19
21
|
TESTV4: "https://test.net955205.contentfabric.io/config"
|
|
20
22
|
},
|
|
23
|
+
playerProfile: {
|
|
24
|
+
DEFAULT: "default",
|
|
25
|
+
LOW_LATENCY: "low_latency"
|
|
26
|
+
},
|
|
21
27
|
drms: {
|
|
22
28
|
FAIRPLAY: "fairplay",
|
|
23
29
|
SAMPLE_AES: "sample-aes",
|
|
@@ -115,6 +121,7 @@ const DefaultParameters = {
|
|
|
115
121
|
posterUrl: undefined,
|
|
116
122
|
className: undefined,
|
|
117
123
|
controlsClassName: undefined,
|
|
124
|
+
playerProfile: EluvioPlayerParameters.playerProfile.DEFAULT,
|
|
118
125
|
hlsjsOptions: undefined,
|
|
119
126
|
dashjsOptions: undefined,
|
|
120
127
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -131,6 +138,17 @@ const DefaultParameters = {
|
|
|
131
138
|
}
|
|
132
139
|
};
|
|
133
140
|
|
|
141
|
+
const PlayerProfiles = {
|
|
142
|
+
default: {
|
|
143
|
+
label: "Default",
|
|
144
|
+
hlsSettings: {},
|
|
145
|
+
},
|
|
146
|
+
low_latency: {
|
|
147
|
+
label: "Low Latency",
|
|
148
|
+
hlsSettings: Utils.LiveHLSJSSettings({lowLatency: true})
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
134
152
|
export class EluvioPlayer {
|
|
135
153
|
constructor(target, parameters) {
|
|
136
154
|
this.warnings = false;
|
|
@@ -415,7 +433,7 @@ export class EluvioPlayer {
|
|
|
415
433
|
|
|
416
434
|
*/
|
|
417
435
|
try {
|
|
418
|
-
if(this.playerOptions.restartCallback) {
|
|
436
|
+
if(error && this.playerOptions.restartCallback) {
|
|
419
437
|
try {
|
|
420
438
|
const abort = await this.playerOptions.restartCallback(error);
|
|
421
439
|
|
|
@@ -433,7 +451,7 @@ export class EluvioPlayer {
|
|
|
433
451
|
|
|
434
452
|
if(this.__destroyed) { return; }
|
|
435
453
|
|
|
436
|
-
this.Log("
|
|
454
|
+
this.Log("Reloading stream");
|
|
437
455
|
|
|
438
456
|
// Recall config to get new nodes
|
|
439
457
|
const client = await this.Client();
|
|
@@ -567,6 +585,15 @@ export class EluvioPlayer {
|
|
|
567
585
|
});
|
|
568
586
|
}
|
|
569
587
|
|
|
588
|
+
// Detect live video
|
|
589
|
+
this.video.addEventListener("durationchange", () => {
|
|
590
|
+
if(this.videoDuration > 0 && this.video.duration !== this.videoDuration) {
|
|
591
|
+
this.isLive = true;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
this.videoDuration = this.video.duration;
|
|
595
|
+
});
|
|
596
|
+
|
|
570
597
|
// Detect removal of video to ensure player is properly destroyed
|
|
571
598
|
this.mutationObserver = new MutationObserver(() => {
|
|
572
599
|
if(this.mutationTimeout) { return; }
|
|
@@ -769,15 +796,11 @@ export class EluvioPlayer {
|
|
|
769
796
|
}
|
|
770
797
|
} else {
|
|
771
798
|
// HLS JS
|
|
772
|
-
|
|
773
799
|
playoutUrl.removeQuery("authorization");
|
|
774
800
|
|
|
775
|
-
|
|
801
|
+
const profileSettings = (PlayerProfiles[this.playerOptions.playerProfile] || {}).hlsSettings || {};
|
|
802
|
+
|
|
776
803
|
const hlsPlayer = new HLSPlayer({
|
|
777
|
-
maxBufferLength: 30,
|
|
778
|
-
maxBufferSize: 300,
|
|
779
|
-
enableWorker: true,
|
|
780
|
-
capLevelToPlayerSize: this.playerOptions.capLevelToPlayerSize,
|
|
781
804
|
xhrSetup: xhr => {
|
|
782
805
|
xhr.setRequestHeader("Authorization", `Bearer ${authorizationToken}`);
|
|
783
806
|
|
|
@@ -787,6 +810,8 @@ export class EluvioPlayer {
|
|
|
787
810
|
|
|
788
811
|
return xhr;
|
|
789
812
|
},
|
|
813
|
+
capLevelToPlayerSize: this.playerOptions.capLevelToPlayerSize,
|
|
814
|
+
...profileSettings,
|
|
790
815
|
...(this.playerOptions.hlsjsOptions || {})
|
|
791
816
|
});
|
|
792
817
|
hlsPlayer.loadSource(playoutUrl.toString());
|
|
@@ -863,6 +888,38 @@ export class EluvioPlayer {
|
|
|
863
888
|
}
|
|
864
889
|
});
|
|
865
890
|
});
|
|
891
|
+
|
|
892
|
+
this.controls.SetPlayerProfileControls({
|
|
893
|
+
GetProfile: () => ({
|
|
894
|
+
label: "Player Profile",
|
|
895
|
+
options: Object.keys(PlayerProfiles).map(key => ({
|
|
896
|
+
index: key,
|
|
897
|
+
label: PlayerProfiles[key].label,
|
|
898
|
+
active: this.playerOptions.playerProfile === key,
|
|
899
|
+
activeLabel: `Player Profile: ${PlayerProfiles[key].label}`
|
|
900
|
+
}))
|
|
901
|
+
}),
|
|
902
|
+
SetProfile: async key => {
|
|
903
|
+
this.playerOptions.playerProfile = key;
|
|
904
|
+
|
|
905
|
+
const playing = !this.video.paused;
|
|
906
|
+
const currentTime = this.video.currentTime;
|
|
907
|
+
|
|
908
|
+
this.hlsPlayer.destroy();
|
|
909
|
+
await this.InitializeHLS({
|
|
910
|
+
playoutUrl,
|
|
911
|
+
authorizationToken,
|
|
912
|
+
drm,
|
|
913
|
+
multiviewOptions
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
PlayPause(this.video, playing);
|
|
917
|
+
|
|
918
|
+
if(!this.isLive) {
|
|
919
|
+
this.video.currentTime = currentTime;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
});
|
|
866
923
|
}
|
|
867
924
|
|
|
868
925
|
hlsPlayer.on(HLSPlayer.Events.FRAG_LOADED, () => {
|
|
@@ -8,6 +8,7 @@ $background-color: $black;
|
|
|
8
8
|
$controls-color: rgba(0, 0, 0, 0.8);
|
|
9
9
|
$menu-color: rgba(0, 0, 0, 0.8);
|
|
10
10
|
$menu-active-color: rgba(255, 255, 255, 0.1);
|
|
11
|
+
$button-inactive-color: rgba($white, 0.7);
|
|
11
12
|
$button-color: rgba($white, 1);
|
|
12
13
|
$progress-color: #0885fb;
|
|
13
14
|
$slider-color: rgba($gray, 0.5);
|
|
@@ -456,7 +457,7 @@ $button-height: 35px;
|
|
|
456
457
|
|
|
457
458
|
&__option {
|
|
458
459
|
border: 1px solid transparent;
|
|
459
|
-
color: $button-color;
|
|
460
|
+
color: $button-inactive-color;
|
|
460
461
|
cursor: pointer;
|
|
461
462
|
display: block;
|
|
462
463
|
font-size: 14px;
|
|
@@ -493,6 +494,7 @@ $button-height: 35px;
|
|
|
493
494
|
|
|
494
495
|
&-selected {
|
|
495
496
|
color: $white;
|
|
497
|
+
font-weight: 500;
|
|
496
498
|
}
|
|
497
499
|
|
|
498
500
|
&:hover {
|