@eluvio/elv-player-js 1.0.96 → 1.0.98
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 +1 -1
- package/src/PlayerControls.js +47 -67
- package/src/index.js +12 -0
- package/src/static/stylesheets/player.scss +25 -18
package/package.json
CHANGED
package/src/PlayerControls.js
CHANGED
|
@@ -115,7 +115,6 @@ class PlayerControls {
|
|
|
115
115
|
this.playerOptions = playerOptions;
|
|
116
116
|
this.timeouts = {};
|
|
117
117
|
this.played = false;
|
|
118
|
-
this.controlsHover = false;
|
|
119
118
|
this.progressHidden = false;
|
|
120
119
|
|
|
121
120
|
if(posterUrl) {
|
|
@@ -140,15 +139,17 @@ class PlayerControls {
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
FadeOut(key, elements, delay=250, callback) {
|
|
142
|
+
FadeOut({key, elements, delay=250, unless, callback}) {
|
|
143
|
+
if(unless && unless()) { return; }
|
|
144
|
+
|
|
144
145
|
clearTimeout(this.timeouts[key]);
|
|
145
146
|
|
|
146
147
|
this.timeouts[key] = setTimeout(() => {
|
|
147
148
|
elements.forEach(element => {
|
|
148
149
|
if(!element) { return; }
|
|
149
150
|
|
|
150
|
-
element.
|
|
151
|
-
element.
|
|
151
|
+
element.classList.add("-elv-fade-out");
|
|
152
|
+
element.classList.remove("-elv-fade-in");
|
|
152
153
|
});
|
|
153
154
|
|
|
154
155
|
if(callback) {
|
|
@@ -157,107 +158,86 @@ class PlayerControls {
|
|
|
157
158
|
}, delay);
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
FadeIn(key, elements) {
|
|
161
|
+
FadeIn({key, elements, callback}) {
|
|
161
162
|
clearTimeout(this.timeouts[key]);
|
|
162
163
|
|
|
163
164
|
elements.forEach(element => {
|
|
164
165
|
if(!element) { return; }
|
|
165
166
|
|
|
166
|
-
element.
|
|
167
|
-
element.
|
|
167
|
+
element.classList.remove("-elv-fade-out");
|
|
168
|
+
element.classList.add("-elv-fade-in");
|
|
168
169
|
});
|
|
169
|
-
}
|
|
170
170
|
|
|
171
|
+
if(callback) {
|
|
172
|
+
callback();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
171
175
|
|
|
172
176
|
AutohideControls(controls) {
|
|
173
177
|
this.video.addEventListener("play", () => {
|
|
174
178
|
this.played = true;
|
|
175
179
|
});
|
|
176
180
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
/*
|
|
182
|
+
Controls should stay visible if:
|
|
183
|
+
- Video hasn't started yet
|
|
184
|
+
- Settings menu is open
|
|
185
|
+
- Currently hovering over controls
|
|
186
|
+
- Currently keyboard-selecting controls
|
|
187
|
+
*/
|
|
188
|
+
const ControlsShouldShow = () => (
|
|
189
|
+
(!this.played && this.video.paused) ||
|
|
190
|
+
(this.settingsMenu && this.settingsMenu.dataset.mode !== "hidden") ||
|
|
191
|
+
!!Array.from(document.querySelectorAll(":hover")).find(element => this.controls.contains(element)) ||
|
|
192
|
+
!!this.controls.contains(document.activeElement) && document.activeElement.classList.contains("focus-visible")
|
|
193
|
+
);
|
|
182
194
|
|
|
183
195
|
const PlayerMove = () => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
this.FadeIn({
|
|
197
|
+
key: "controls",
|
|
198
|
+
elements: [controls, this.settingsMenu, this.toolTip],
|
|
199
|
+
callback: () => {
|
|
200
|
+
this.target.classList.remove("-elv-no-cursor");
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
this.FadeOut({
|
|
204
|
+
key: "controls",
|
|
205
|
+
elements: [controls, this.settingsMenu, this.toolTip],
|
|
206
|
+
delay: 3000,
|
|
207
|
+
unless: () => ControlsShouldShow(),
|
|
208
|
+
callback: () => {
|
|
209
|
+
this.target.classList.add("-elv-no-cursor");
|
|
210
|
+
}
|
|
211
|
+
});
|
|
188
212
|
|
|
189
213
|
this.target.style.cursor = "unset";
|
|
190
214
|
};
|
|
191
215
|
|
|
192
|
-
const ControlsIn = () => {
|
|
193
|
-
clearTimeout(this.timeouts.controls);
|
|
194
|
-
this.controlsHover = true;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const ControlsOut = () => this.controlsHover = false;
|
|
198
|
-
|
|
199
216
|
// Play / Pause
|
|
200
217
|
this.video.addEventListener("play", () => PlayerMove);
|
|
201
218
|
this.video.addEventListener("pause", () => PlayerMove);
|
|
202
219
|
|
|
203
220
|
// Mouse events
|
|
204
221
|
this.target.addEventListener("mousemove", PlayerMove);
|
|
205
|
-
this.target.addEventListener("mouseleave", PlayerOut);
|
|
206
|
-
controls.addEventListener("mouseenter", ControlsIn);
|
|
207
|
-
controls.addEventListener("mouseleave", ControlsOut);
|
|
208
222
|
|
|
209
|
-
if(this.settingsMenu) {
|
|
210
|
-
this.settingsMenu.addEventListener("mouseenter", ControlsIn);
|
|
211
|
-
this.settingsMenu.addEventListener("mouseleave", ControlsOut);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if(this.toolTip) {
|
|
215
|
-
this.toolTip.addEventListener("mouseenter", ControlsIn);
|
|
216
|
-
this.toolTip.addEventListener("mouseleave", ControlsOut);
|
|
217
|
-
}
|
|
218
223
|
|
|
219
224
|
// Touch events
|
|
220
225
|
this.target.addEventListener("touchmove", PlayerMove);
|
|
221
|
-
this.target.addEventListener("touchleave", PlayerOut);
|
|
222
|
-
controls.addEventListener("touchmove", ControlsIn);
|
|
223
|
-
controls.addEventListener("touchleave", ControlsOut);
|
|
224
|
-
controls.addEventListener("touchend", () => { ControlsOut(); PlayerOut(); });
|
|
225
|
-
|
|
226
|
-
if(this.settingsMenu) {
|
|
227
|
-
this.settingsMenu.addEventListener("touchmove", ControlsIn);
|
|
228
|
-
this.settingsMenu.addEventListener("touchleave", ControlsOut);
|
|
229
|
-
this.settingsMenu.addEventListener("touchend", () => {
|
|
230
|
-
ControlsOut();
|
|
231
|
-
PlayerOut();
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if(this.toolTip) {
|
|
236
|
-
this.toolTip.addEventListener("touchmove", ControlsIn);
|
|
237
|
-
this.toolTip.addEventListener("touchleave", ControlsOut);
|
|
238
|
-
this.toolTip.addEventListener("touchend", () => {
|
|
239
|
-
ControlsOut();
|
|
240
|
-
PlayerOut();
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
226
|
|
|
244
227
|
// Keyboard events
|
|
245
228
|
this.target.addEventListener("blur", () => setTimeout(() => {
|
|
246
229
|
if(!this.target.contains(document.activeElement)) {
|
|
247
|
-
|
|
248
|
-
ControlsOut();
|
|
230
|
+
PlayerMove();
|
|
249
231
|
}
|
|
250
232
|
}), 2000);
|
|
251
233
|
|
|
252
|
-
window.addEventListener("blur", () => {
|
|
234
|
+
window.addEventListener("blur", () => { PlayerMove(); });
|
|
253
235
|
|
|
254
236
|
Array.from(this.target.querySelectorAll("button, input")).forEach(button => {
|
|
255
|
-
button.addEventListener("focus", () => { PlayerMove();
|
|
237
|
+
button.addEventListener("focus", () => { PlayerMove(); });
|
|
256
238
|
});
|
|
257
239
|
|
|
258
|
-
|
|
259
|
-
PlayerOut();
|
|
260
|
-
}
|
|
240
|
+
PlayerMove();
|
|
261
241
|
}
|
|
262
242
|
|
|
263
243
|
InitializeControls(className="") {
|
|
@@ -380,12 +360,12 @@ class PlayerControls {
|
|
|
380
360
|
});
|
|
381
361
|
|
|
382
362
|
this.video.addEventListener("play", () => {
|
|
383
|
-
this.FadeOut("big-play-button", [this.bigPlayButton]);
|
|
363
|
+
this.FadeOut({key: "big-play-button", elements: [this.bigPlayButton]});
|
|
384
364
|
|
|
385
365
|
// Prevent big play button from flashing
|
|
386
366
|
setTimeout(() => this.target.classList.remove("eluvio-player-restarted"), 1000);
|
|
387
367
|
});
|
|
388
|
-
this.video.addEventListener("pause", () => this.FadeIn("big-play-button", [this.bigPlayButton]));
|
|
368
|
+
this.video.addEventListener("pause", () => this.FadeIn({key: "big-play-button", elements: [this.bigPlayButton]}));
|
|
389
369
|
|
|
390
370
|
this.bigPlayButton.style.display = this.video.paused ? null : "none";
|
|
391
371
|
this.bigPlayButton.addEventListener("click", () => this.video.play());
|
package/src/index.js
CHANGED
|
@@ -373,6 +373,10 @@ export class EluvioPlayer {
|
|
|
373
373
|
|
|
374
374
|
this.Log("Destroying player");
|
|
375
375
|
|
|
376
|
+
if(this.video) {
|
|
377
|
+
this.video.pause();
|
|
378
|
+
}
|
|
379
|
+
|
|
376
380
|
if(this.player.destroy) {
|
|
377
381
|
this.player.destroy();
|
|
378
382
|
} else if(this.player.reset) {
|
|
@@ -582,6 +586,14 @@ export class EluvioPlayer {
|
|
|
582
586
|
|
|
583
587
|
let { protocol, drm, playoutUrl, drms, multiviewOptions } = await playoutOptionsPromise;
|
|
584
588
|
|
|
589
|
+
if(["fairplay", "sample-aes"].includes(drm)) {
|
|
590
|
+
// Switch to default controls if using fairplay or sample aes
|
|
591
|
+
if(this.playerOptions.controls !== EluvioPlayerParameters.controls.OFF) {
|
|
592
|
+
this.playerOptions.controls = EluvioPlayerParameters.controls.DEFAULT;
|
|
593
|
+
this.video.controls = true;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
585
597
|
this.controls = new PlayerControls({
|
|
586
598
|
target: this.target,
|
|
587
599
|
video: this.video,
|
|
@@ -41,6 +41,7 @@ $button-height: 35px;
|
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
font-family: "Helvetica Neue", Helvetica, sans-serif;
|
|
43
43
|
line-height: 1;
|
|
44
|
+
overscroll-behavior-y: contain; // sass-lint:disable-line no-misspelled-properties
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
// sass-lint:disable force-attribute-nesting no-qualifying-elements
|
|
@@ -460,26 +461,9 @@ $button-height: 35px;
|
|
|
460
461
|
}
|
|
461
462
|
}
|
|
462
463
|
|
|
463
|
-
&.eluvio-player-autohide {
|
|
464
|
-
.eluvio-player__controls {
|
|
465
|
-
opacity: 0;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
464
|
&:fullscreen {
|
|
470
465
|
margin: 0;
|
|
471
|
-
max-height: unset;
|
|
472
|
-
max-width: unset;
|
|
473
|
-
min-height: 100vh;
|
|
474
|
-
min-width: 100vw;
|
|
475
466
|
padding: 0;
|
|
476
|
-
|
|
477
|
-
video {
|
|
478
|
-
max-height: unset;
|
|
479
|
-
max-width: unset;
|
|
480
|
-
min-height: 100%;
|
|
481
|
-
min-width: 100%;
|
|
482
|
-
}
|
|
483
467
|
}
|
|
484
468
|
|
|
485
469
|
&__ticket-modal {
|
|
@@ -697,7 +681,7 @@ $button-height: 35px;
|
|
|
697
681
|
align-items: center;
|
|
698
682
|
height: 100%;
|
|
699
683
|
max-height: 100%;
|
|
700
|
-
padding: 80px 0
|
|
684
|
+
padding: 80px 0 100px;
|
|
701
685
|
right: 0;
|
|
702
686
|
top: 0;
|
|
703
687
|
width: 100%;
|
|
@@ -728,6 +712,29 @@ $button-height: 35px;
|
|
|
728
712
|
}
|
|
729
713
|
}
|
|
730
714
|
|
|
715
|
+
// sass-lint:disable no-important
|
|
716
|
+
.-elv-fade-in,
|
|
717
|
+
.-elv-fade-out {
|
|
718
|
+
transition: opacity 0.25s linear;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
.-elv-fade-out {
|
|
722
|
+
opacity: 0 !important;
|
|
723
|
+
pointer-events: none !important;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.-elv-fade-in {
|
|
727
|
+
opacity: 1;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.-elv-no-cursor {
|
|
731
|
+
cursor: none !important;
|
|
732
|
+
|
|
733
|
+
* {
|
|
734
|
+
cursor: none !important;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
731
738
|
// sass-lint:disable no-color-literals
|
|
732
739
|
@keyframes hotspot-select {
|
|
733
740
|
0% {
|