@eluvio/elv-player-js 1.0.61 → 1.0.65
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-lock.json +1 -1
- package/package.json +1 -1
- package/src/PlayerControls.js +97 -33
- package/src/index.js +15 -0
- package/src/static/stylesheets/player.scss +54 -4
package/package-lock.json
CHANGED
package/package.json
CHANGED
package/src/PlayerControls.js
CHANGED
|
@@ -14,6 +14,28 @@ import Logo from "./static/images/ELUV.IO white 20 px V2.png";
|
|
|
14
14
|
|
|
15
15
|
import {EluvioPlayerParameters} from "./index";
|
|
16
16
|
|
|
17
|
+
const lsKeyPrefix = "@eluvio/elv-player";
|
|
18
|
+
export const LocalStorage = {
|
|
19
|
+
getItem: (key) => {
|
|
20
|
+
try {
|
|
21
|
+
return localStorage.getItem(`${lsKeyPrefix}-${key}`);
|
|
22
|
+
// eslint-disable-next-line no-empty
|
|
23
|
+
} catch (error) {}
|
|
24
|
+
},
|
|
25
|
+
setItem: (key, value) => {
|
|
26
|
+
try {
|
|
27
|
+
localStorage.setItem(`${lsKeyPrefix}-${key}`, value);
|
|
28
|
+
// eslint-disable-next-line no-empty
|
|
29
|
+
} catch (error) {}
|
|
30
|
+
},
|
|
31
|
+
removeItem: (key) => {
|
|
32
|
+
try {
|
|
33
|
+
localStorage.removeItem(`${lsKeyPrefix}-${key}`);
|
|
34
|
+
// eslint-disable-next-line no-empty
|
|
35
|
+
} catch (error) {}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
17
39
|
export const CreateElement = ({parent, type="div", label, options={}, classes=[], prepend=false}) => {
|
|
18
40
|
const element = document.createElement(type);
|
|
19
41
|
classes.filter(c => c).forEach(c => element.classList.add(c));
|
|
@@ -92,6 +114,15 @@ class PlayerControls {
|
|
|
92
114
|
this.playerOptions = playerOptions;
|
|
93
115
|
this.posterUrl = posterUrl;
|
|
94
116
|
|
|
117
|
+
if(posterUrl) {
|
|
118
|
+
// Preload poster before setting it
|
|
119
|
+
const imagePreload = new Image();
|
|
120
|
+
imagePreload.src = posterUrl;
|
|
121
|
+
imagePreload.onload = () => {
|
|
122
|
+
this.video.poster = posterUrl;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
95
126
|
this.settingsMenuContent = "none";
|
|
96
127
|
this.timeouts = {};
|
|
97
128
|
this.played = false;
|
|
@@ -143,6 +174,41 @@ class PlayerControls {
|
|
|
143
174
|
watermark.src = Logo;
|
|
144
175
|
}
|
|
145
176
|
|
|
177
|
+
// Poster
|
|
178
|
+
/*
|
|
179
|
+
if(this.posterUrl) {
|
|
180
|
+
this.poster = CreateElement({
|
|
181
|
+
parent: this.target,
|
|
182
|
+
type: "img",
|
|
183
|
+
classes: ["eluvio-player__poster-image"],
|
|
184
|
+
label: "Poster Image",
|
|
185
|
+
options: {
|
|
186
|
+
src: this.posterUrl
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
this.video.addEventListener("play", () => {
|
|
191
|
+
if(this.poster) {
|
|
192
|
+
if(this.poster.parentNode) {
|
|
193
|
+
this.poster.parentNode.removeChild(this.poster);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.poster = undefined;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
this.poster.addEventListener("click", () => this.video.play());
|
|
201
|
+
this.poster.addEventListener("error", () => {
|
|
202
|
+
if(this.poster.parentNode) {
|
|
203
|
+
this.poster.parentNode.removeChild(this.poster);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this.poster = undefined;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
*/
|
|
211
|
+
|
|
146
212
|
if(
|
|
147
213
|
this.playerOptions.controls === EluvioPlayerParameters.controls.DEFAULT ||
|
|
148
214
|
this.playerOptions.controls === EluvioPlayerParameters.controls.OFF
|
|
@@ -184,28 +250,6 @@ class PlayerControls {
|
|
|
184
250
|
return;
|
|
185
251
|
}
|
|
186
252
|
|
|
187
|
-
// Poster
|
|
188
|
-
if(this.posterUrl) {
|
|
189
|
-
this.poster = CreateElement({
|
|
190
|
-
parent: this.target,
|
|
191
|
-
type: "img",
|
|
192
|
-
classes: ["eluvio-player__poster-image"],
|
|
193
|
-
label: "Poster Image",
|
|
194
|
-
options: {
|
|
195
|
-
src: this.posterUrl
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
this.poster.addEventListener("click", () => this.video.play());
|
|
200
|
-
this.poster.addEventListener("error", () => {
|
|
201
|
-
if(this.poster.parentNode) {
|
|
202
|
-
this.poster.parentNode.removeChild(this.poster);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
this.poster = undefined;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
253
|
// Controls container
|
|
210
254
|
const controls = CreateElement({
|
|
211
255
|
parent: this.target,
|
|
@@ -213,6 +257,8 @@ class PlayerControls {
|
|
|
213
257
|
classes: ["eluvio-player__controls"]
|
|
214
258
|
});
|
|
215
259
|
|
|
260
|
+
this.controls = controls;
|
|
261
|
+
|
|
216
262
|
// Play / Pause
|
|
217
263
|
const playPauseButton = CreateImageButton({
|
|
218
264
|
parent: controls,
|
|
@@ -387,6 +433,13 @@ class PlayerControls {
|
|
|
387
433
|
|
|
388
434
|
this.target.addEventListener("keydown", event => event && (event.key || "").toLowerCase() === "escape" && this.HideSettingsMenu());
|
|
389
435
|
|
|
436
|
+
// Settings Menu
|
|
437
|
+
this.toolTip = CreateElement({
|
|
438
|
+
parent: this.target,
|
|
439
|
+
type: "div",
|
|
440
|
+
classes: ["eluvio-player__controls__tooltip"]
|
|
441
|
+
});
|
|
442
|
+
|
|
390
443
|
// Event Listeners
|
|
391
444
|
|
|
392
445
|
const ProgressSlider = () => {
|
|
@@ -432,14 +485,6 @@ class PlayerControls {
|
|
|
432
485
|
this.video.addEventListener("play", () => {
|
|
433
486
|
this.played = true;
|
|
434
487
|
|
|
435
|
-
if(this.poster) {
|
|
436
|
-
if(this.poster.parentNode) {
|
|
437
|
-
this.poster.parentNode.removeChild(this.poster);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
this.poster = undefined;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
488
|
playPauseButton.innerHTML = PauseIcon;
|
|
444
489
|
playPauseButton.classList.add("eluvio-player__controls__button-pause");
|
|
445
490
|
playPauseButton.setAttribute("aria-label", "Pause");
|
|
@@ -484,14 +529,14 @@ class PlayerControls {
|
|
|
484
529
|
const PlayerOut = () => {
|
|
485
530
|
if(!this.played) { return; }
|
|
486
531
|
|
|
487
|
-
this.FadeOut("controls", [controls, this.settingsMenu], 2000);
|
|
532
|
+
this.FadeOut("controls", [controls, this.settingsMenu, this.toolTip], 2000);
|
|
488
533
|
};
|
|
489
534
|
|
|
490
535
|
const PlayerMove = () => {
|
|
491
536
|
if(this.controlsHover) { return; }
|
|
492
537
|
|
|
493
|
-
this.FadeIn("controls", [controls, this.settingsMenu]);
|
|
494
|
-
this.FadeOut("controls", [controls, this.settingsMenu], 3000, () => this.target.style.cursor = "none");
|
|
538
|
+
this.FadeIn("controls", [controls, this.settingsMenu, this.toolTip]);
|
|
539
|
+
this.FadeOut("controls", [controls, this.settingsMenu, this.toolTip], 3000, () => this.target.style.cursor = "none");
|
|
495
540
|
|
|
496
541
|
this.target.style.cursor = "unset";
|
|
497
542
|
};
|
|
@@ -514,6 +559,8 @@ class PlayerControls {
|
|
|
514
559
|
controls.addEventListener("mouseleave", ControlsOut);
|
|
515
560
|
this.settingsMenu.addEventListener("mouseenter", ControlsIn);
|
|
516
561
|
this.settingsMenu.addEventListener("mouseleave", ControlsOut);
|
|
562
|
+
this.toolTip.addEventListener("mouseenter", ControlsIn);
|
|
563
|
+
this.toolTip.addEventListener("mouseleave", ControlsOut);
|
|
517
564
|
|
|
518
565
|
// Touch events
|
|
519
566
|
this.target.addEventListener("touchmove", PlayerMove);
|
|
@@ -524,6 +571,9 @@ class PlayerControls {
|
|
|
524
571
|
this.settingsMenu.addEventListener("touchmove", ControlsIn);
|
|
525
572
|
this.settingsMenu.addEventListener("touchleave", ControlsOut);
|
|
526
573
|
this.settingsMenu.addEventListener("touchend", () => { ControlsOut(); PlayerOut(); });
|
|
574
|
+
this.toolTip.addEventListener("touchmove", ControlsIn);
|
|
575
|
+
this.toolTip.addEventListener("touchleave", ControlsOut);
|
|
576
|
+
this.toolTip.addEventListener("touchend", () => { ControlsOut(); PlayerOut(); });
|
|
527
577
|
|
|
528
578
|
// Keyboard events
|
|
529
579
|
this.target.addEventListener("blur", () => setTimeout(() => {
|
|
@@ -682,6 +732,20 @@ class PlayerControls {
|
|
|
682
732
|
this.InitializeMultiviewHotspots(hot_spots, SwitchView);
|
|
683
733
|
}
|
|
684
734
|
});
|
|
735
|
+
|
|
736
|
+
if(!LocalStorage.getItem("multiview-tooltip")) {
|
|
737
|
+
setTimeout(() => {
|
|
738
|
+
this.toolTip.innerHTML = `${MultiViewIcon}<div>This stream has multiple views! Click this button to switch between them.</div>`;
|
|
739
|
+
|
|
740
|
+
const ClearTooltip = () => {
|
|
741
|
+
this.toolTip.innerHTML = "";
|
|
742
|
+
LocalStorage.setItem("multiview-tooltip", "1");
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
this.toolTip.addEventListener("click", ClearTooltip);
|
|
746
|
+
this.controls.addEventListener("click", ClearTooltip);
|
|
747
|
+
}, 2000);
|
|
748
|
+
}
|
|
685
749
|
}
|
|
686
750
|
|
|
687
751
|
async ToggleMultiviewControls({AvailableViews, SwitchView}={}) {
|
package/src/index.js
CHANGED
|
@@ -55,6 +55,10 @@ export const EluvioPlayerParameters = {
|
|
|
55
55
|
settings: {
|
|
56
56
|
OFF: false,
|
|
57
57
|
ON: true
|
|
58
|
+
},
|
|
59
|
+
capLevelToPlayerSize: {
|
|
60
|
+
OFF: false,
|
|
61
|
+
ON: true
|
|
58
62
|
}
|
|
59
63
|
};
|
|
60
64
|
|
|
@@ -580,6 +584,7 @@ export class EluvioPlayer {
|
|
|
580
584
|
maxBufferLength: 30,
|
|
581
585
|
maxBufferSize: 300,
|
|
582
586
|
enableWorker: true,
|
|
587
|
+
capLevelToPlayerSize: this.playerOptions.capLevelToPlayerSize,
|
|
583
588
|
xhrSetup: xhr => {
|
|
584
589
|
xhr.setRequestHeader("Authorization", `Bearer ${authorizationToken}`);
|
|
585
590
|
|
|
@@ -648,6 +653,16 @@ export class EluvioPlayer {
|
|
|
648
653
|
const DashPlayer = (await import("dashjs")).default;
|
|
649
654
|
dashPlayer = DashPlayer.MediaPlayer().create();
|
|
650
655
|
|
|
656
|
+
if(this.playerOptions.capLevelToPlayerSize) {
|
|
657
|
+
dashPlayer.updateSettings({
|
|
658
|
+
"streaming": {
|
|
659
|
+
"abr": {
|
|
660
|
+
"limitBitrateByPortal": true
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
|
|
651
666
|
playoutUrl.removeQuery("authorization");
|
|
652
667
|
dashPlayer.extend("RequestModifier", function () {
|
|
653
668
|
return {
|
|
@@ -295,10 +295,46 @@ $button-height: 35px;
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
+
&__tooltip {
|
|
299
|
+
background: $controls-color;
|
|
300
|
+
border-radius: 3px;
|
|
301
|
+
bottom: 45px;
|
|
302
|
+
color: $button-color;
|
|
303
|
+
font-size: 14px;
|
|
304
|
+
font-weight: 300;
|
|
305
|
+
max-height: calc(100% - 54px);
|
|
306
|
+
max-width: 225px;
|
|
307
|
+
min-height: 20px;
|
|
308
|
+
opacity: 1;
|
|
309
|
+
padding: 10px 5px;
|
|
310
|
+
pointer-events: none;
|
|
311
|
+
position: absolute;
|
|
312
|
+
right: 10px;
|
|
313
|
+
text-align: center;
|
|
314
|
+
transition: opacity 0.1s linear;
|
|
315
|
+
user-select: none;
|
|
316
|
+
z-index: 100;
|
|
317
|
+
|
|
318
|
+
* {
|
|
319
|
+
line-height: 1.2em;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
&:empty {
|
|
323
|
+
display: none;
|
|
324
|
+
opacity: 0;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
svg {
|
|
328
|
+
height: 20px;
|
|
329
|
+
margin-bottom: 5px;
|
|
330
|
+
width: auto;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
298
334
|
&__settings-menu {
|
|
299
335
|
background: $controls-color;
|
|
300
336
|
border-radius: 3px;
|
|
301
|
-
bottom:
|
|
337
|
+
bottom: 45px;
|
|
302
338
|
color: $button-color;
|
|
303
339
|
max-height: calc(100% - 54px);
|
|
304
340
|
min-height: 20px;
|
|
@@ -535,6 +571,11 @@ $button-height: 35px;
|
|
|
535
571
|
.eluvio-player__controls {
|
|
536
572
|
height: CALC(#{$controls-height} * 1.5);
|
|
537
573
|
padding: 0 CALC(#{$controls-padding} * 1.5);
|
|
574
|
+
|
|
575
|
+
&__tooltip,
|
|
576
|
+
&__settings-menu {
|
|
577
|
+
bottom: 65px;
|
|
578
|
+
}
|
|
538
579
|
}
|
|
539
580
|
}
|
|
540
581
|
|
|
@@ -562,7 +603,6 @@ $button-height: 35px;
|
|
|
562
603
|
display: none;
|
|
563
604
|
}
|
|
564
605
|
|
|
565
|
-
|
|
566
606
|
.eluvio-player__big-play-button {
|
|
567
607
|
max-height: 75px;
|
|
568
608
|
max-width: 75px;
|
|
@@ -589,9 +629,19 @@ $button-height: 35px;
|
|
|
589
629
|
&.eluvio-player-s {
|
|
590
630
|
.eluvio-player__controls {
|
|
591
631
|
padding: 5px;
|
|
632
|
+
}
|
|
592
633
|
|
|
593
|
-
|
|
594
|
-
|
|
634
|
+
.eluvio-player__controls__time {
|
|
635
|
+
display: none;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.eluvio-player__controls__tooltip {
|
|
639
|
+
font-size: 10px;
|
|
640
|
+
max-width: 180px;
|
|
641
|
+
|
|
642
|
+
svg {
|
|
643
|
+
height: 15px;
|
|
644
|
+
width: 15px;
|
|
595
645
|
}
|
|
596
646
|
}
|
|
597
647
|
|