@latest-thinking/lt-player 1.0.4-o → 1.0.4-p
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/js/lt-player-main.js +1 -1
- package/dist/js/lt-player-main.js.map +1 -1
- package/package.json +1 -1
- package/src/components/LTPlayerSetup.ts +26 -2
- package/src/components/LTPlayerType.ts +11 -7
- package/src/components/config/LTPlayerConfig.ts +184 -0
- package/src/components/config/LTPlayerConfigProcessor.ts +496 -0
- package/src/components/controls/LTPlayerControls.ts +1 -1
- package/src/components/poster/LTPlayerPoster.ts +1 -1
- package/src/components/poster/LTPlayerPosterManager.ts +1 -1
- package/src/components/poster/LTPlayerPosterPreload.ts +1 -1
- package/src/components/share/LTPlayerShare.ts +1 -1
- package/src/global/controllers/LTPlayerController.ts +1 -1
- package/src/services/Helper.ts +20 -5
- package/src/services/TemplateService.ts +1 -1
- package/src/views/template.handlebars +2 -2
- package/src/components/LTPlayerConfig.ts +0 -398
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import {defaultType, urlDataType} from "../../global/types/ModuleTypes";
|
|
2
|
+
import {Helper} from "../../services/Helper";
|
|
3
|
+
|
|
4
|
+
export namespace LTPlayerConfigProcessor {
|
|
5
|
+
export class Map {
|
|
6
|
+
version : number
|
|
7
|
+
|
|
8
|
+
setVersion(version : number) {
|
|
9
|
+
this.version = version;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
processItem(name: string, value : any) {
|
|
13
|
+
return this.mapByVersion(name, value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mapByVersion(name: string, value : any) {
|
|
17
|
+
switch (name) {
|
|
18
|
+
case 'preload':
|
|
19
|
+
return Processor.processPreload(value, this.version);
|
|
20
|
+
case 'autoPlay' :
|
|
21
|
+
return Processor.processAutoPlay(value, this.version);
|
|
22
|
+
case 'videoTitle' :
|
|
23
|
+
return Processor.processVideoTitle(value, this.version);
|
|
24
|
+
case 'posterImage' :
|
|
25
|
+
return Processor.processPosterImage(value, this.version);
|
|
26
|
+
case 'videoParagraph':
|
|
27
|
+
return Processor.processVideoParagraph(value, this.version);
|
|
28
|
+
case 'videoUrl' :
|
|
29
|
+
return Processor.processVideoUrl(value, this.version);
|
|
30
|
+
case 'playerContainer' :
|
|
31
|
+
return Processor.processPlayerContainer(value, this.version);
|
|
32
|
+
case 'share':
|
|
33
|
+
return Processor.processShareData(value, this.version);
|
|
34
|
+
case 'vimeo':
|
|
35
|
+
return Processor.processVimeoConfig(value, this.version);
|
|
36
|
+
case 'defaultConfig':
|
|
37
|
+
return Processor.processDefaultConfig(value, this.version);
|
|
38
|
+
case 'chapters':
|
|
39
|
+
return Processor.processChapters(value, this.version);
|
|
40
|
+
case 'device':
|
|
41
|
+
if (this.version === 1) {
|
|
42
|
+
return value.device;
|
|
43
|
+
} else {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
case 'playerType':
|
|
47
|
+
if (this.version === 1) {
|
|
48
|
+
return value.playerType;
|
|
49
|
+
} else {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class Processor {
|
|
57
|
+
|
|
58
|
+
static processChapters(data : defaultType, version : number) {
|
|
59
|
+
|
|
60
|
+
if(!data) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (version === 1) {
|
|
65
|
+
data = data.chapters;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (Object.keys(data).length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return data;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
static processDefaultConfig(data : defaultType, version : number) {
|
|
78
|
+
let outputData : defaultType = {
|
|
79
|
+
speed : {
|
|
80
|
+
selected : 1,
|
|
81
|
+
captions : false,
|
|
82
|
+
update: true
|
|
83
|
+
},
|
|
84
|
+
captions : {
|
|
85
|
+
active : false
|
|
86
|
+
},
|
|
87
|
+
clickToPlay : false,
|
|
88
|
+
playsinline : true,
|
|
89
|
+
pip : false
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!data) {
|
|
93
|
+
return outputData;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (version === 1) {
|
|
97
|
+
return outputData;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (Object.keys(data).length === 0) {
|
|
101
|
+
return outputData;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
Object.keys(data).forEach(item => {
|
|
105
|
+
if (outputData[item] !== undefined) {
|
|
106
|
+
outputData[item] = data[item];
|
|
107
|
+
} else {
|
|
108
|
+
outputData[item] = data[item];
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
return outputData;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static processVimeoConfig(data : defaultType, version : number) {
|
|
117
|
+
|
|
118
|
+
let outputData : defaultType = {
|
|
119
|
+
controls: false,
|
|
120
|
+
active: false,
|
|
121
|
+
gesture: 'media',
|
|
122
|
+
transparent: false,
|
|
123
|
+
speed: true,
|
|
124
|
+
portrait: true,
|
|
125
|
+
keyboard: false,
|
|
126
|
+
title: false,
|
|
127
|
+
byline: false,
|
|
128
|
+
playsinline: true,
|
|
129
|
+
background: true
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (version === 1) {
|
|
133
|
+
return outputData
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!data) {
|
|
137
|
+
return outputData;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (Object.keys(data).length === 0){
|
|
141
|
+
return outputData;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
Object.keys(data).forEach(item => {
|
|
145
|
+
if (outputData[item] !== undefined) {
|
|
146
|
+
outputData[item] = data[item];
|
|
147
|
+
} else {
|
|
148
|
+
outputData[item] = data[item];
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
return outputData;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static processShareData(data : defaultType, version : number) {
|
|
156
|
+
if (!data) {
|
|
157
|
+
return null
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (version === 1) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type shareDataConfig = {
|
|
165
|
+
canonicalUrl : string,
|
|
166
|
+
embedUrl : string,
|
|
167
|
+
title : string
|
|
168
|
+
} | null
|
|
169
|
+
|
|
170
|
+
let outputData : shareDataConfig = {
|
|
171
|
+
canonicalUrl : undefined,
|
|
172
|
+
embedUrl : undefined,
|
|
173
|
+
title : undefined
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (Object.keys(data).length === 0) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (data.canonicalUrl !== undefined) {
|
|
181
|
+
outputData.canonicalUrl = data.canonicalUrl;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (data.embedUrl !== undefined) {
|
|
185
|
+
outputData.embedUrl = data.embedUrl;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (data.title !== undefined) {
|
|
189
|
+
outputData.title = data.title;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return outputData;
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static processPlayerContainer(data : Element | defaultType, version : number) {
|
|
197
|
+
if (!data) {
|
|
198
|
+
return null
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (version === 1) {
|
|
202
|
+
return (data as defaultType).playerContainer;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return data;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static processVideoUrl(data : string | defaultType, version : number) {
|
|
209
|
+
|
|
210
|
+
if (!data) {
|
|
211
|
+
return null
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if (version === 1) {
|
|
216
|
+
if (typeof data === 'object') {
|
|
217
|
+
data = data.sources.video_id;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
type configData = {videoUrl : string, videoType : string, embedId : string, embedHash : string, origin : string};
|
|
222
|
+
|
|
223
|
+
let outputData : configData = {
|
|
224
|
+
videoUrl : undefined,
|
|
225
|
+
videoType : undefined,
|
|
226
|
+
embedHash : undefined,
|
|
227
|
+
embedId : undefined,
|
|
228
|
+
origin : undefined
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!Helper.isValidHttpUrl(data)) {
|
|
232
|
+
console.error(`Please insert valid url video url videoURL : ${data}`);
|
|
233
|
+
return outputData
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const urlVideoData: urlDataType = Helper.processConfigData(data);
|
|
237
|
+
|
|
238
|
+
const mapVideoData = (data: string | defaultType, urlVideoData: urlDataType, outputData: configData) => {
|
|
239
|
+
|
|
240
|
+
if (typeof data === "string") {
|
|
241
|
+
outputData.videoUrl = data;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (urlVideoData.origin) {
|
|
245
|
+
outputData.origin = urlVideoData.origin;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (urlVideoData.type) {
|
|
249
|
+
outputData.videoType = urlVideoData.type.toLowerCase()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (urlVideoData.type === 'embedded') {
|
|
253
|
+
const embedID = Helper.getEmbeddedID(data);
|
|
254
|
+
|
|
255
|
+
if (embedID) {
|
|
256
|
+
outputData.embedId = embedID;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const embedHash = Helper.getEmbeddedHash(data);
|
|
260
|
+
|
|
261
|
+
if (embedHash) {
|
|
262
|
+
outputData.embedHash = embedHash;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return outputData;
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
outputData = mapVideoData(data, urlVideoData, outputData);
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
return outputData;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
static processVideoParagraph(data : string | defaultType, version : number) {
|
|
278
|
+
|
|
279
|
+
if (!data) {
|
|
280
|
+
return null
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
let outputData = undefined;
|
|
284
|
+
|
|
285
|
+
if (version === 1) {
|
|
286
|
+
if (typeof data === 'object') {
|
|
287
|
+
data = data.author;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (typeof data === 'string' && /[a-zA-Z]/.test(data)){
|
|
292
|
+
outputData = data;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return outputData;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
static processPosterImage(data: string | defaultType, version : number) {
|
|
299
|
+
|
|
300
|
+
if (!data) {
|
|
301
|
+
return null
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (version === 1) {
|
|
305
|
+
if (typeof data === 'object') {
|
|
306
|
+
return data.poster;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
let check = Helper.isValidHttpUrl(data);
|
|
311
|
+
|
|
312
|
+
if (check) {
|
|
313
|
+
return data;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
console.error(`Set valid url for poster image config item => posterImage : ${data} `);
|
|
317
|
+
return undefined;
|
|
318
|
+
}
|
|
319
|
+
static processVideoTitle(data : string | defaultType, version : number) {
|
|
320
|
+
|
|
321
|
+
if (!data) {
|
|
322
|
+
return null
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let outputData = undefined;
|
|
326
|
+
|
|
327
|
+
if (version === 1) {
|
|
328
|
+
if (typeof data === 'object') {
|
|
329
|
+
data = data.title;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (data) {
|
|
334
|
+
if (typeof data === 'string' && /[a-zA-Z]/.test(data)){
|
|
335
|
+
outputData = data;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return outputData;
|
|
340
|
+
}
|
|
341
|
+
static processAutoPlay(data : boolean | string | object, version : number) {
|
|
342
|
+
|
|
343
|
+
if (!data) {
|
|
344
|
+
return null
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let outputData : boolean = false;
|
|
348
|
+
|
|
349
|
+
if (version === 1) {
|
|
350
|
+
return outputData;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
if (typeof data === 'string') {
|
|
355
|
+
if (data === 'true') {
|
|
356
|
+
outputData = true;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (typeof data === 'boolean') {
|
|
361
|
+
if (data) {
|
|
362
|
+
outputData = true;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return outputData;
|
|
367
|
+
}
|
|
368
|
+
static processPreload(data : object | null, version : number) {
|
|
369
|
+
|
|
370
|
+
if (!data) {
|
|
371
|
+
return null
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (version === 1) {
|
|
375
|
+
return
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
type outputType = {start : number, stop : number, autoType : boolean, isActive : boolean};
|
|
379
|
+
const setTimeRange = (config: defaultType, itemOutput : outputType) => {
|
|
380
|
+
|
|
381
|
+
if (config.start) {
|
|
382
|
+
|
|
383
|
+
let start = config.start;
|
|
384
|
+
|
|
385
|
+
if (typeof start === 'string') {
|
|
386
|
+
start = parseFloat(start);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
itemOutput.start = start;
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
if (!start) {
|
|
393
|
+
itemOutput.start = 0;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (config.stop) {
|
|
398
|
+
|
|
399
|
+
let stop = config.stop;
|
|
400
|
+
|
|
401
|
+
if (typeof stop === 'string') {
|
|
402
|
+
stop = parseFloat(stop);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
itemOutput.stop = stop;
|
|
406
|
+
|
|
407
|
+
if (!stop) {
|
|
408
|
+
itemOutput.stop = 10;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return itemOutput;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const setPreloadType = (type: defaultType, itemOutput : outputType) => {
|
|
417
|
+
|
|
418
|
+
itemOutput.autoType = true;
|
|
419
|
+
|
|
420
|
+
if (type.onload !== undefined) {
|
|
421
|
+
if (typeof type.onload === 'string' && type.onload === 'false') {
|
|
422
|
+
itemOutput.autoType = false;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (typeof type.onload === 'boolean') {
|
|
426
|
+
if (!type.onload) {
|
|
427
|
+
itemOutput.autoType = false;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return itemOutput;
|
|
433
|
+
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const setActive = (itemOutput : outputType) => {
|
|
437
|
+
itemOutput.isActive = true;
|
|
438
|
+
return itemOutput
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
let itemOutput : outputType = {
|
|
444
|
+
start : 0,
|
|
445
|
+
stop : 10,
|
|
446
|
+
isActive : false,
|
|
447
|
+
autoType : false,
|
|
448
|
+
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
if (typeof data === 'object') {
|
|
452
|
+
if (Object.keys(data).length !== 0) {
|
|
453
|
+
itemOutput = setTimeRange(data, itemOutput);
|
|
454
|
+
itemOutput = setPreloadType(data, itemOutput);
|
|
455
|
+
itemOutput = setActive(itemOutput);
|
|
456
|
+
|
|
457
|
+
return itemOutput;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (Object.keys(data).length === 0) {
|
|
461
|
+
itemOutput = setPreloadType(data, itemOutput);
|
|
462
|
+
itemOutput = setActive(itemOutput);
|
|
463
|
+
|
|
464
|
+
return itemOutput
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return false
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (typeof data === 'string' && data !== 'false') {
|
|
471
|
+
|
|
472
|
+
if (data === 'true') {
|
|
473
|
+
itemOutput = setPreloadType(data, itemOutput);
|
|
474
|
+
itemOutput = setActive(itemOutput);
|
|
475
|
+
return itemOutput;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (typeof data === 'boolean') {
|
|
482
|
+
if (data) {
|
|
483
|
+
itemOutput = setPreloadType(data, itemOutput);
|
|
484
|
+
itemOutput = setActive(itemOutput);
|
|
485
|
+
return itemOutput;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Plyr from "plyr";
|
|
2
2
|
import {TemplateService} from "../../services/TemplateService";
|
|
3
|
-
import {LTPlayerConfig} from "../LTPlayerConfig";
|
|
3
|
+
import {LTPlayerConfig} from "../config/LTPlayerConfig";
|
|
4
4
|
import {IconsService} from "../../services/IconsService";
|
|
5
5
|
import {LTPlayerChapters} from "./LTPlayerChapters";
|
|
6
6
|
import {LTPlayerSettingsControlsManager} from "./LTPlayerSettingsControlsManager";
|
|
@@ -2,7 +2,7 @@ import {LTPlayerPosterPreload} from "./LTPlayerPosterPreload";
|
|
|
2
2
|
import {LTPlayerPoster} from "./LTPlayerPoster";
|
|
3
3
|
import {LTPlayer} from "../LTPlayerType";
|
|
4
4
|
import {LTPlayerDevMethode} from "../LTPlayerDevMethode";
|
|
5
|
-
import {LTPlayerConfig} from "../LTPlayerConfig";
|
|
5
|
+
import {LTPlayerConfig} from "../config/LTPlayerConfig";
|
|
6
6
|
import {TemplateService} from "../../services/TemplateService";
|
|
7
7
|
import {IconsService} from "../../services/IconsService";
|
|
8
8
|
import {LTPlayerPosterEvents} from "./LTPlayerPosterEvents";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {LTPlayerPoster} from "./LTPlayerPoster";
|
|
2
2
|
import Plyr from "plyr";
|
|
3
3
|
import {TemplateService} from "../../services/TemplateService";
|
|
4
|
-
import {LTPlayerConfig} from "../LTPlayerConfig";
|
|
4
|
+
import {LTPlayerConfig} from "../config/LTPlayerConfig";
|
|
5
5
|
import {IconsService} from "../../services/IconsService";
|
|
6
6
|
import {LoaderService} from "../../services/LoaderService";
|
|
7
7
|
import {LTPlayer} from "../LTPlayerType";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {LTPlayer} from "../LTPlayerType";
|
|
2
|
-
import {LTPlayerConfig} from "../LTPlayerConfig";
|
|
2
|
+
import {LTPlayerConfig} from "../config/LTPlayerConfig";
|
|
3
3
|
import {IconsService} from "../../services/IconsService";
|
|
4
4
|
import {TemplateService} from "../../services/TemplateService";
|
|
5
5
|
import {LTPlayerShareEvents} from "./LTPlayerShareEvents";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {LTPlayerConfig} from "../../components/LTPlayerConfig";
|
|
1
|
+
import {LTPlayerConfig} from "../../components/config/LTPlayerConfig";
|
|
2
2
|
import {LTPlayerControls} from "../../components/controls/LTPlayerControls";
|
|
3
3
|
import Plyr from "plyr";
|
|
4
4
|
import {TemplateService} from "../../services/TemplateService";
|
package/src/services/Helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {defaultType} from "../global/types/ModuleTypes";
|
|
2
2
|
|
|
3
3
|
export class Helper {
|
|
4
4
|
static getDevice() {
|
|
@@ -28,7 +28,7 @@ export class Helper {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
static processConfigData(videoUrl: string) {
|
|
31
|
+
static processConfigData(videoUrl: string | defaultType) {
|
|
32
32
|
|
|
33
33
|
const regex = /^(http:\/\/|https:\/\/)(player\.vimeo\.com|vimeo\.com|youtu\.be|www\.youtube\.com)\/([\w\/]+)(\?.*)?$/;
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ export class Helper {
|
|
|
36
36
|
let type = 'video';
|
|
37
37
|
let origin = 'video';
|
|
38
38
|
|
|
39
|
-
if ((groupMatch = regex.exec(videoUrl)) !== null) {
|
|
39
|
+
if ((groupMatch = regex.exec(<string>videoUrl)) !== null) {
|
|
40
40
|
groupMatch.forEach((match: string) => {
|
|
41
41
|
if (match !== undefined) {
|
|
42
42
|
if (match.includes('vimeo')) {
|
|
@@ -57,7 +57,7 @@ export class Helper {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
static getEmbeddedID = (url: string) => {
|
|
60
|
+
static getEmbeddedID = (url: string | defaultType) => {
|
|
61
61
|
const urlGroups = url.split('?')[0].split('/');
|
|
62
62
|
if (urlGroups.length > 4) {
|
|
63
63
|
return url.split('?')[0].split('/').slice(-2)[0];
|
|
@@ -66,11 +66,26 @@ export class Helper {
|
|
|
66
66
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
static getEmbeddedHash = (url: string) => {
|
|
69
|
+
static getEmbeddedHash = (url: string | defaultType) => {
|
|
70
70
|
const urlGroups = url.split('?')[0].split('/');
|
|
71
71
|
if (urlGroups.length > 4) {
|
|
72
72
|
return url.split('?')[0].split('/').slice(-1)[0];
|
|
73
73
|
}
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
static isValidHttpUrl(string: string | defaultType) {
|
|
78
|
+
let url;
|
|
79
|
+
|
|
80
|
+
if (typeof string === 'object') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
url = new URL(string);
|
|
86
|
+
} catch (_) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
90
|
+
}
|
|
76
91
|
}
|
|
@@ -8,7 +8,7 @@ import share from '../views/share.handlebars';
|
|
|
8
8
|
import background from '../views/background.handlebars';
|
|
9
9
|
import miniPlayerControls from '../views/controls.handlebars';
|
|
10
10
|
import onloadPoster from '../views/onloadPoster.handlebars';
|
|
11
|
-
import {LTPlayerConfig} from "../components/LTPlayerConfig";
|
|
11
|
+
import {LTPlayerConfig} from "../components/config/LTPlayerConfig";
|
|
12
12
|
import {IconsService} from "./IconsService";
|
|
13
13
|
import {defaultType} from "../global/types/ModuleTypes";
|
|
14
14
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{{#embedded }}
|
|
2
|
-
<div class="plyr__video-embed embed_player" data-plyr-provider="{{origin}}" data-plyr-embed-id="{{embedId}}" data-plyr-embed-hash="{{embedHash}}">
|
|
2
|
+
<div class="plyr__video-embed embed_player" data-plyr-provider="{{videoUrl.origin}}" data-plyr-embed-id="{{videoUrl.embedId}}" data-plyr-embed-hash="{{videoUrl.embedHash}}">
|
|
3
3
|
</div>
|
|
4
4
|
{{/embedded}}
|
|
5
5
|
{{#video}}
|
|
6
6
|
<video class="embed_player lt-player-wrapper" playsinline controls>
|
|
7
|
-
<source src="{{videoUrl}}"/>
|
|
7
|
+
<source src="{{videoUrl.videoUrl}}"/>
|
|
8
8
|
{{#defaultConfig.captions}}
|
|
9
9
|
<track kind="captions" label="{{label}} captions" src="{{url}}" srclang="{{srclang}}" {{default}} />
|
|
10
10
|
{{/defaultConfig.captions}}
|