@eluvio/elv-player-js 1.0.117 → 1.0.119
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 +65 -68
- package/src/index.js +55 -48
- package/src/static/stylesheets/player.scss +7 -7
package/src/PlayerControls.js
CHANGED
|
@@ -120,8 +120,73 @@ const Time = (time, total) => {
|
|
|
120
120
|
return string;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
+
export const InitializeTicketPrompt = (target, callback) => {
|
|
124
|
+
const ticketModal = CreateElement({
|
|
125
|
+
parent: target,
|
|
126
|
+
type: "div",
|
|
127
|
+
classes: ["eluvio-player__ticket-modal"]
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
ticketModal.addEventListener("dblclick", event => event.stopPropagation());
|
|
131
|
+
|
|
132
|
+
const form = CreateElement({
|
|
133
|
+
parent: ticketModal,
|
|
134
|
+
type: "form",
|
|
135
|
+
classes: ["eluvio-player__ticket-modal__form"]
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const errorMessage = CreateElement({
|
|
139
|
+
parent: form,
|
|
140
|
+
type: "div",
|
|
141
|
+
classes: ["eluvio-player__ticket-modal__form__error-text", "eluvio-player__ticket-modal__form__text"]
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const text = CreateElement({
|
|
145
|
+
parent: form,
|
|
146
|
+
type: "div",
|
|
147
|
+
classes: ["eluvio-player__ticket-modal__form__text"]
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
text.innerHTML = "Enter your code";
|
|
151
|
+
|
|
152
|
+
const input = CreateElement({
|
|
153
|
+
parent: form,
|
|
154
|
+
type: "input",
|
|
155
|
+
classes: ["eluvio-player__ticket-modal__form__input"]
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const submit = CreateElement({
|
|
159
|
+
parent: form,
|
|
160
|
+
type: "button",
|
|
161
|
+
classes: ["eluvio-player__ticket-modal__form__submit"]
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
input.focus();
|
|
165
|
+
|
|
166
|
+
submit.innerHTML = "Submit";
|
|
167
|
+
|
|
168
|
+
submit.addEventListener("click", async event => {
|
|
169
|
+
try {
|
|
170
|
+
submit.setAttribute("disabled", true);
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
errorMessage.innerHTML = "";
|
|
173
|
+
|
|
174
|
+
await callback(input.value);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
// eslint-disable-next-line no-console
|
|
177
|
+
console.error("ELUVIO PLAYER: Invalid Code");
|
|
178
|
+
// eslint-disable-next-line no-console
|
|
179
|
+
console.error(error);
|
|
180
|
+
|
|
181
|
+
errorMessage.innerHTML = "Invalid Code";
|
|
182
|
+
submit.removeAttribute("disabled");
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
123
187
|
class PlayerControls {
|
|
124
188
|
constructor({target, video, playerOptions, posterUrl, className}) {
|
|
189
|
+
console.log(new Error("init player controls"))
|
|
125
190
|
this.target = target;
|
|
126
191
|
this.video = video;
|
|
127
192
|
this.playerOptions = playerOptions;
|
|
@@ -1046,74 +1111,6 @@ class PlayerControls {
|
|
|
1046
1111
|
});
|
|
1047
1112
|
}
|
|
1048
1113
|
|
|
1049
|
-
InitializeTicketPrompt(callback) {
|
|
1050
|
-
if(this.bigPlayButton) {
|
|
1051
|
-
this.bigPlayButton.parentNode.removeChild(this.bigPlayButton);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
const ticketModal = CreateElement({
|
|
1055
|
-
parent: this.target,
|
|
1056
|
-
type: "div",
|
|
1057
|
-
classes: ["eluvio-player__ticket-modal"]
|
|
1058
|
-
});
|
|
1059
|
-
|
|
1060
|
-
ticketModal.addEventListener("dblclick", event => event.stopPropagation());
|
|
1061
|
-
|
|
1062
|
-
const form = CreateElement({
|
|
1063
|
-
parent: ticketModal,
|
|
1064
|
-
type: "form",
|
|
1065
|
-
classes: ["eluvio-player__ticket-modal__form"]
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
const errorMessage = CreateElement({
|
|
1069
|
-
parent: form,
|
|
1070
|
-
type: "div",
|
|
1071
|
-
classes: ["eluvio-player__ticket-modal__form__error-text", "eluvio-player__ticket-modal__form__text"]
|
|
1072
|
-
});
|
|
1073
|
-
|
|
1074
|
-
const text = CreateElement({
|
|
1075
|
-
parent: form,
|
|
1076
|
-
type: "div",
|
|
1077
|
-
classes: ["eluvio-player__ticket-modal__form__text"]
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
text.innerHTML = "Enter your code";
|
|
1081
|
-
|
|
1082
|
-
const input = CreateElement({
|
|
1083
|
-
parent: form,
|
|
1084
|
-
type: "input",
|
|
1085
|
-
classes: ["eluvio-player__ticket-modal__form__input"]
|
|
1086
|
-
});
|
|
1087
|
-
|
|
1088
|
-
const submit = CreateElement({
|
|
1089
|
-
parent: form,
|
|
1090
|
-
type: "button",
|
|
1091
|
-
classes: ["eluvio-player__ticket-modal__form__submit"]
|
|
1092
|
-
});
|
|
1093
|
-
|
|
1094
|
-
input.focus();
|
|
1095
|
-
|
|
1096
|
-
submit.innerHTML = "Submit";
|
|
1097
|
-
|
|
1098
|
-
submit.addEventListener("click", async event => {
|
|
1099
|
-
try {
|
|
1100
|
-
submit.setAttribute("disabled", true);
|
|
1101
|
-
event.preventDefault();
|
|
1102
|
-
errorMessage.innerHTML = "";
|
|
1103
|
-
|
|
1104
|
-
await callback(input.value);
|
|
1105
|
-
} catch (error) {
|
|
1106
|
-
// eslint-disable-next-line no-console
|
|
1107
|
-
console.error("ELUVIO PLAYER: Invalid Code");
|
|
1108
|
-
// eslint-disable-next-line no-console
|
|
1109
|
-
console.error(error);
|
|
1110
|
-
|
|
1111
|
-
errorMessage.innerHTML = "Invalid Code";
|
|
1112
|
-
submit.removeAttribute("disabled");
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
1114
|
HandleResize({width, height}) {
|
|
1118
1115
|
const ratio = width / height;
|
|
1119
1116
|
const targetRatio = 16 / 9;
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import URI from "urijs";
|
|
|
9
9
|
import ResizeObserver from "resize-observer-polyfill";
|
|
10
10
|
|
|
11
11
|
import {InitializeFairPlayStream} from "./FairPlay";
|
|
12
|
-
import PlayerControls, {CreateElement, PlayPause} from "./PlayerControls";
|
|
12
|
+
import PlayerControls, {CreateElement, InitializeTicketPrompt, PlayPause} from "./PlayerControls";
|
|
13
13
|
|
|
14
14
|
export const EluvioPlayerParameters = {
|
|
15
15
|
networks: {
|
|
@@ -208,6 +208,7 @@ export class EluvioPlayer {
|
|
|
208
208
|
await this.clientPromise;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
// Always initialize new client if ticket is used
|
|
211
212
|
if(!this.clientOptions.client) {
|
|
212
213
|
this.clientPromise = new Promise(async resolve => {
|
|
213
214
|
const {ElvClient} = await import("@eluvio/elv-client-js");
|
|
@@ -221,33 +222,35 @@ export class EluvioPlayer {
|
|
|
221
222
|
this.clientOptions.client.utils.B64(JSON.stringify({qspace_id: await this.clientOptions.client.ContentSpaceId()}))
|
|
222
223
|
});
|
|
223
224
|
|
|
224
|
-
resolve();
|
|
225
|
+
resolve(this.clientOptions.client);
|
|
225
226
|
});
|
|
226
227
|
|
|
227
228
|
await this.clientPromise;
|
|
228
229
|
}
|
|
229
230
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
let code = this.clientOptions.ticketCode;
|
|
234
|
-
let subject = this.clientOptions.ticketSubject;
|
|
235
|
-
if(code.includes(":")) {
|
|
236
|
-
subject = code.split(":")[0];
|
|
237
|
-
code = code.split(":")[1];
|
|
238
|
-
}
|
|
231
|
+
return this.clientOptions.client;
|
|
232
|
+
}
|
|
239
233
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
ntpId: this.clientOptions.ntpId,
|
|
243
|
-
code,
|
|
244
|
-
email: subject
|
|
245
|
-
});
|
|
234
|
+
async RedeemCode(code) {
|
|
235
|
+
if(!this.clientOptions.tenantId) { throw Error("ELUVIO PLAYER: Tenant ID must be provided if ticket code is specified."); }
|
|
246
236
|
|
|
247
|
-
|
|
237
|
+
code = code || this.clientOptions.ticketCode;
|
|
238
|
+
let subject = this.clientOptions.ticketSubject;
|
|
239
|
+
if(code.includes(":")) {
|
|
240
|
+
subject = code.split(":")[0];
|
|
241
|
+
code = code.split(":")[1];
|
|
248
242
|
}
|
|
249
243
|
|
|
250
|
-
|
|
244
|
+
await (await this.Client()).RedeemCode({
|
|
245
|
+
tenantId: this.clientOptions.tenantId,
|
|
246
|
+
ntpId: this.clientOptions.ntpId,
|
|
247
|
+
code,
|
|
248
|
+
email: subject
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
this.ticketInitialized = true;
|
|
252
|
+
this.clientOptions.ticketCode = code;
|
|
253
|
+
this.originalParameters.clientOptions.ticketCode = code;
|
|
251
254
|
}
|
|
252
255
|
|
|
253
256
|
async PosterUrl() {
|
|
@@ -472,10 +475,43 @@ export class EluvioPlayer {
|
|
|
472
475
|
this.clientOptions = parameters.clientOptions;
|
|
473
476
|
this.sourceOptions = parameters.sourceOptions;
|
|
474
477
|
this.playerOptions = parameters.playerOptions;
|
|
478
|
+
|
|
479
|
+
// If ticket redemption required, ensure new client is used unless specified
|
|
480
|
+
if(
|
|
481
|
+
this.clientOptions.promptTicket &&
|
|
482
|
+
!this.ticketInitialized &&
|
|
483
|
+
!this.clientOptions.allowClientTicketRedemption
|
|
484
|
+
) {
|
|
485
|
+
this.clientOptions.client = undefined;
|
|
486
|
+
}
|
|
475
487
|
}
|
|
476
488
|
|
|
477
489
|
this.errors = 0;
|
|
478
490
|
|
|
491
|
+
|
|
492
|
+
this.target.classList.add("eluvio-player");
|
|
493
|
+
|
|
494
|
+
// Start client loading
|
|
495
|
+
this.Client();
|
|
496
|
+
|
|
497
|
+
if(this.clientOptions.promptTicket && !this.ticketInitialized) {
|
|
498
|
+
if(!this.clientOptions.tenantId) {
|
|
499
|
+
throw Error("ELUVIO PLAYER: Tenant ID must be provided if ticket code is needed.");
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if(this.clientOptions.ticketCode) {
|
|
503
|
+
await this.RedeemCode(this.clientOptions.ticketCode);
|
|
504
|
+
} else {
|
|
505
|
+
InitializeTicketPrompt(this.target, async code => {
|
|
506
|
+
await this.RedeemCode(code);
|
|
507
|
+
|
|
508
|
+
this.Initialize(target, parameters);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
479
515
|
try {
|
|
480
516
|
const playoutOptionsPromise = this.PlayoutOptions();
|
|
481
517
|
|
|
@@ -569,35 +605,6 @@ export class EluvioPlayer {
|
|
|
569
605
|
});
|
|
570
606
|
this.resizeObserver.observe(this.target);
|
|
571
607
|
|
|
572
|
-
if(this.clientOptions.promptTicket && !this.clientOptions.ticketCode) {
|
|
573
|
-
if(!this.clientOptions.tenantId) { throw Error("ELUVIO PLAYER: Tenant ID must be provided if ticket code is needed."); }
|
|
574
|
-
|
|
575
|
-
this.controls.InitializeTicketPrompt(async (code) => {
|
|
576
|
-
code = (code || "").trim();
|
|
577
|
-
let subject = this.clientOptions.ticketSubject;
|
|
578
|
-
if(code.includes(":")) {
|
|
579
|
-
subject = code.split(":")[0];
|
|
580
|
-
code = code.split(":")[1];
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
await this.clientOptions.client.RedeemCode({
|
|
584
|
-
tenantId: this.clientOptions.tenantId,
|
|
585
|
-
ntpId: this.clientOptions.ntpId,
|
|
586
|
-
code,
|
|
587
|
-
email: subject
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
this.ticketInitialized = true;
|
|
591
|
-
this.clientOptions.ticketCode = code;
|
|
592
|
-
this.originalParameters.clientOptions.client = this.clientOptions.client;
|
|
593
|
-
this.originalParameters.clientOptions.ticketCode = code;
|
|
594
|
-
|
|
595
|
-
this.Initialize(this.target);
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
608
|
let { protocol, drm, playoutUrl, drms, multiviewOptions } = await playoutOptionsPromise;
|
|
602
609
|
|
|
603
610
|
this.PosterUrl().then(posterUrl => this.controls.SetPosterUrl(posterUrl));
|
|
@@ -8,7 +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-color: rgba($white,
|
|
11
|
+
$button-color: rgba($white, 1);
|
|
12
12
|
$progress-color: #0885fb;
|
|
13
13
|
$slider-color: rgba($gray, 0.5);
|
|
14
14
|
$hotspot-color: rgba($gray, 0.3);
|
|
@@ -201,7 +201,7 @@ $button-height: 35px;
|
|
|
201
201
|
|
|
202
202
|
&__video {
|
|
203
203
|
background: $background-color;
|
|
204
|
-
height:
|
|
204
|
+
height: 100%;
|
|
205
205
|
margin: auto;
|
|
206
206
|
object-fit: contain;
|
|
207
207
|
object-position: center;
|
|
@@ -528,7 +528,7 @@ $button-height: 35px;
|
|
|
528
528
|
|
|
529
529
|
&__ticket-modal {
|
|
530
530
|
align-items: center;
|
|
531
|
-
background: $
|
|
531
|
+
background: $background-color;
|
|
532
532
|
display: flex;
|
|
533
533
|
height: 100%;
|
|
534
534
|
justify-content: center;
|
|
@@ -554,7 +554,7 @@ $button-height: 35px;
|
|
|
554
554
|
|
|
555
555
|
&__text {
|
|
556
556
|
color: $button-color;
|
|
557
|
-
font-size:
|
|
557
|
+
font-size: 16px;
|
|
558
558
|
font-weight: 300;
|
|
559
559
|
letter-spacing: 0.05em;
|
|
560
560
|
}
|
|
@@ -569,14 +569,14 @@ $button-height: 35px;
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
&__input {
|
|
572
|
-
background: $
|
|
572
|
+
background: $white;
|
|
573
573
|
border: 0;
|
|
574
574
|
border-radius: 3px;
|
|
575
575
|
font-size: 18px;
|
|
576
576
|
font-weight: bold;
|
|
577
577
|
letter-spacing: 0.16em;
|
|
578
578
|
margin: 5px 0 15px;
|
|
579
|
-
min-height:
|
|
579
|
+
min-height: 36px;
|
|
580
580
|
padding: 0 10px;
|
|
581
581
|
text-align: center;
|
|
582
582
|
width: 100%;
|
|
@@ -585,7 +585,7 @@ $button-height: 35px;
|
|
|
585
585
|
&__submit {
|
|
586
586
|
border-radius: 3px;
|
|
587
587
|
color: $button-color;
|
|
588
|
-
font-size:
|
|
588
|
+
font-size: 14px;
|
|
589
589
|
font-weight: 500;
|
|
590
590
|
height: 40px;
|
|
591
591
|
letter-spacing: 0.1em;
|