@latest-thinking/lt-player 1.0.5 → 1.0.6-b
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/.babelrc +2 -1
- package/dist/css/lt-player-main.css +1 -1
- package/dist/css/lt-player-main.css.map +1 -1
- package/dist/js/lt-player-main.js +1 -1
- package/dist/js/lt-player-main.js.map +1 -1
- package/package.json +5 -3
- package/src/assets/sass/abstracts/_mixins.scss +5 -5
- package/src/assets/sass/abstracts/_placeholders.scss +5 -5
- package/src/assets/sass/abstracts/_variables.scss +7 -7
- package/src/assets/sass/components/_modal.scss +61 -19
- package/src/assets/sass/sections/_additional-info.scss +6 -6
- package/src/assets/sass/sections/_control.scss +12 -11
- package/src/assets/sass/sections/_poster.scss +52 -10
- package/src/assets/sass/sections/_settings.scss +14 -12
- package/src/assets/sass/sections/_share.scss +263 -95
- package/src/assets/sass/sections/_subtitles.scss +14 -1
- package/src/assets/sass/sections/controllers/_botom.scss +160 -98
- package/src/assets/sass/sections/controllers/_mini-player.scss +18 -3
- package/src/assets/sass/sections/controllers/_notification-rewind-forward.scss +48 -85
- package/src/assets/sass/sections/controllers/_top.scss +39 -13
- package/src/components/LTPlayerDevMethode.ts +23 -3
- package/src/components/LTPlayerHls.ts +29 -0
- package/src/components/LTPlayerSetup.ts +14 -9
- package/src/components/LTPlayerType.ts +85 -37
- package/src/components/addInfo/LTPlayerAddInfoManager.ts +12 -5
- package/src/components/addInfo/LTPlayerAdditionalInfoEvents.ts +37 -12
- package/src/components/config/LTPlayerConfig.ts +44 -1
- package/src/components/config/LTPlayerConfigProcessor.ts +9 -5
- package/src/components/controls/LTPlayerControlsEvents.ts +26 -10
- package/src/components/controls/LTPlayerMini.ts +75 -5
- package/src/components/controls/settings/LTPlayerDesktopSettingsControllers.ts +2 -2
- package/src/components/controls/settings/LTPlayerMobileSettingsControllers.ts +4 -4
- package/src/components/events/LTPlayer.ts +10 -1
- package/src/components/events/LTPlayerCommon.ts +7 -8
- package/src/components/events/LTPlayerDesktop.ts +29 -2
- package/src/components/events/LTPlayerMobile.ts +27 -0
- package/src/components/poster/LTPlayerPoster.ts +36 -22
- package/src/components/poster/LTPlayerPosterEvents.ts +10 -7
- package/src/components/poster/LTPlayerPosterManager.ts +3 -10
- package/src/components/share/LTPlayerShareDesktop.ts +120 -0
- package/src/components/share/LTPlayerShareEvents.ts +30 -69
- package/src/components/share/{LTPlayerShare.ts → LTPlayerShareManager.ts} +26 -8
- package/src/components/share/LTPlayerShareMobile.ts +154 -0
- package/src/components/video/LTPlayerVideo.ts +49 -0
- package/src/global/controllers/LTPlayerController.ts +8 -3
- package/src/services/Helper.ts +24 -0
- package/src/services/ResizeService.ts +33 -10
- package/src/views/additionalInfo.handlebars +58 -0
- package/src/views/background.handlebars +1 -1
- package/src/views/controls.handlebars +6 -6
- package/src/views/poster.handlebars +2 -1
- package/src/views/share.handlebars +81 -78
|
@@ -8,8 +8,8 @@ import {LTPlayerDevMethode} from "./LTPlayerDevMethode";
|
|
|
8
8
|
import {LTPlayerEventsManager} from "./LTPlayerEventsManager";
|
|
9
9
|
import {LTPLayerAddInfo} from "./addInfo/LTPlayerAddInfoManager";
|
|
10
10
|
import {LTPlayerEvents} from "./events/LTPlayer";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import {Helper} from "../services/Helper";
|
|
12
|
+
import {LTPlayerHls} from "./LTPlayerHls";
|
|
13
13
|
|
|
14
14
|
export namespace LTPlayer {
|
|
15
15
|
|
|
@@ -39,8 +39,16 @@ export namespace LTPlayer {
|
|
|
39
39
|
this.additionalInfoService = additionalInfoService;
|
|
40
40
|
this.miniPlayer = new LTPlayerMini();
|
|
41
41
|
this.setPlayerConfig(configData.body, configData.version);
|
|
42
|
-
this.initSetupPlayerPoster(configData.body);
|
|
43
42
|
this.initPlayer();
|
|
43
|
+
|
|
44
|
+
if (this.additionalInfoService) {
|
|
45
|
+
this.additionalInfoService.init(this, this.playerConfig.getPlayerId(), this.iconService, this.templateService)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (Helper.checkIsHls(this.playerConfig.getVideoUrl().videoUrl)){
|
|
49
|
+
this.hls = new LTPlayerHls(this, undefined);
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
this.setEvents();
|
|
45
53
|
|
|
46
54
|
return true;
|
|
@@ -50,14 +58,6 @@ export namespace LTPlayer {
|
|
|
50
58
|
setEvents() {
|
|
51
59
|
this.eventInstance = new LTPlayerEventsManager(this);
|
|
52
60
|
}
|
|
53
|
-
|
|
54
|
-
private initSetupPlayerPoster(configData: defaultType) {
|
|
55
|
-
const playerContainer = configData.playerContainer;
|
|
56
|
-
playerContainer.classList.add('d-none')
|
|
57
|
-
const logo: string = this.iconService.getLogo();
|
|
58
|
-
playerContainer.insertAdjacentHTML("afterend", this.templateService.getOnloadPoster({logo: logo})) ;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
61
|
setDesktopEvents() {
|
|
62
62
|
this.desktopEvents = new LTPlayerEvents.Desktop();
|
|
63
63
|
}
|
|
@@ -106,21 +106,19 @@ export namespace LTPlayer {
|
|
|
106
106
|
|
|
107
107
|
this.playerConfig.getPlayerElementContainer().classList.add(`lt-player-portrate--${this.playerConfig.getDevice()}`);
|
|
108
108
|
|
|
109
|
-
|
|
110
109
|
let playerSettings = {};
|
|
111
110
|
|
|
112
111
|
const controls = this.getPlayerControllers();
|
|
113
112
|
|
|
114
113
|
Object.assign(playerSettings, {controls});
|
|
115
114
|
|
|
116
|
-
|
|
117
115
|
if (this.playerConfig.getVideoType() === 'embedded') {
|
|
118
116
|
Object.assign(playerSettings, this.playerConfig.getEmbedOrigin())
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
Object.assign(playerSettings, this.playerConfig.getDefaultConfigItems());
|
|
122
120
|
|
|
123
|
-
Object.assign(playerSettings, {
|
|
121
|
+
Object.assign(playerSettings, {ratio : '9:16'});
|
|
124
122
|
|
|
125
123
|
if (this.playerConfig.getFullscreenMode()) {
|
|
126
124
|
Object.assign(playerSettings, this.playerConfig.getFullscreenMode());
|
|
@@ -128,7 +126,15 @@ export namespace LTPlayer {
|
|
|
128
126
|
|
|
129
127
|
const element = this.playerConfig.getPlayerElementContainer().querySelector('.embed_player');
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
this.plyr = new Plyr(element, playerSettings);
|
|
130
|
+
|
|
131
|
+
this.playerConfig.setObjectFit(this.plyr, 'portrait').then(() => {
|
|
132
|
+
this.videoService.init(this);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
this.windowService.init(this);
|
|
136
|
+
|
|
137
|
+
this.posterManager.init(this);
|
|
132
138
|
|
|
133
139
|
const chapters = this.playerConfig.getChapters();
|
|
134
140
|
|
|
@@ -136,18 +142,14 @@ export namespace LTPlayer {
|
|
|
136
142
|
this.playerControl.initChapters(this.playerConfig.getChapters());
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
this.
|
|
140
|
-
|
|
141
|
-
this.devMethodePlayer = new LTPlayerDevMethode.Player(player);
|
|
142
|
-
|
|
143
|
-
this.posterManager.init(this);
|
|
145
|
+
this.devMethodePlayer = new LTPlayerDevMethode.Player(this);
|
|
144
146
|
|
|
145
147
|
if (this.playerConfig.getShareData()) {
|
|
146
148
|
this.share.init(this);
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
if (this.playerConfig.getDevice() !== 'mobile') {
|
|
150
|
-
this.miniPlayer.init(
|
|
152
|
+
this.miniPlayer.init(this.plyr, this.templateService, this.iconService, this.playerConfig.getPlayerType(), this);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -167,6 +169,13 @@ export namespace LTPlayer {
|
|
|
167
169
|
return this.devMethodePreload;
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
enterMiniPlayer() {
|
|
173
|
+
return this.devMethodePlayer.enterMiniPlayer()
|
|
174
|
+
}
|
|
175
|
+
exitMiniPlayer() {
|
|
176
|
+
return this.devMethodePlayer.exitMiniPlayer()
|
|
177
|
+
}
|
|
178
|
+
|
|
170
179
|
destruct() {
|
|
171
180
|
let _this = this;
|
|
172
181
|
|
|
@@ -210,8 +219,14 @@ export namespace LTPlayer {
|
|
|
210
219
|
|
|
211
220
|
this.miniPlayer = new LTPlayerMini();
|
|
212
221
|
this.setPlayerConfig(configData.body, configData.version);
|
|
213
|
-
this.initPoster(configData.body);
|
|
214
222
|
this.initPlayer();
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if (Helper.checkIsHls(this.playerConfig.getVideoUrl().videoUrl)){
|
|
226
|
+
this.hls = new LTPlayerHls(this, undefined);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
215
230
|
this.setEvents();
|
|
216
231
|
|
|
217
232
|
return true;
|
|
@@ -239,7 +254,7 @@ export namespace LTPlayer {
|
|
|
239
254
|
|
|
240
255
|
Object.assign(playerSettings, this.playerConfig.getDefaultConfigItems());
|
|
241
256
|
|
|
242
|
-
Object.assign(playerSettings, {
|
|
257
|
+
Object.assign(playerSettings, {ratio : '16:9'});
|
|
243
258
|
|
|
244
259
|
if (this.playerConfig.getFullscreenMode()) {
|
|
245
260
|
Object.assign(playerSettings, this.playerConfig.getFullscreenMode());
|
|
@@ -247,7 +262,15 @@ export namespace LTPlayer {
|
|
|
247
262
|
|
|
248
263
|
const element = this.playerConfig.getPlayerElementContainer().querySelector('.embed_player');
|
|
249
264
|
|
|
250
|
-
|
|
265
|
+
this.plyr = new Plyr(element, playerSettings);
|
|
266
|
+
|
|
267
|
+
this.playerConfig.setObjectFit(this.plyr, 'landscape').then(() => {
|
|
268
|
+
this.videoService.init(this);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
this.windowService.init(this);
|
|
272
|
+
|
|
273
|
+
this.posterManager.init(this);
|
|
251
274
|
|
|
252
275
|
const chapters = this.playerConfig.getChapters();
|
|
253
276
|
|
|
@@ -255,18 +278,14 @@ export namespace LTPlayer {
|
|
|
255
278
|
this.playerControl.initChapters(this.playerConfig.getChapters());
|
|
256
279
|
}
|
|
257
280
|
|
|
258
|
-
this.
|
|
259
|
-
|
|
260
|
-
this.devMethodePlayer = new LTPlayerDevMethode.Player(player);
|
|
261
|
-
|
|
262
|
-
this.posterManager.init(this);
|
|
281
|
+
this.devMethodePlayer = new LTPlayerDevMethode.Player(this);
|
|
263
282
|
|
|
264
283
|
if (this.playerConfig.getShareData()) {
|
|
265
284
|
this.share.init(this);
|
|
266
285
|
}
|
|
267
286
|
|
|
268
287
|
if (this.playerConfig.getDevice() !== 'mobile') {
|
|
269
|
-
this.miniPlayer.init(
|
|
288
|
+
this.miniPlayer.init(this.plyr, this.templateService, this.iconService, this.playerConfig.getPlayerType(), this);
|
|
270
289
|
}
|
|
271
290
|
}
|
|
272
291
|
|
|
@@ -279,13 +298,6 @@ export namespace LTPlayer {
|
|
|
279
298
|
playerContainer.innerHTML = this.templateService.getTemplateByType(config);
|
|
280
299
|
}
|
|
281
300
|
|
|
282
|
-
initPoster(configData: defaultType) {
|
|
283
|
-
const playerContainer = configData.playerContainer;
|
|
284
|
-
playerContainer.classList.add('d-none')
|
|
285
|
-
const logo: string = this.iconService.getLogo();
|
|
286
|
-
playerContainer.insertAdjacentHTML("afterend", this.templateService.getOnloadPoster({logo: logo})) ;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
301
|
private setPlayerConfig(configData: playerConfigType, version: string | number) {
|
|
290
302
|
this.playerConfig = new LTPlayerConfig(version);
|
|
291
303
|
this.playerConfig.mapConfigData(configData);
|
|
@@ -295,7 +307,43 @@ export namespace LTPlayer {
|
|
|
295
307
|
return this.plyr;
|
|
296
308
|
}
|
|
297
309
|
|
|
310
|
+
play() {
|
|
311
|
+
this.devMethodePlayer.play();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
pause() {
|
|
315
|
+
this.devMethodePlayer.pause();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
stop() {
|
|
319
|
+
this.devMethodePlayer.stop();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
preload() {
|
|
323
|
+
return this.devMethodePreload;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
enterMiniPlayer() {
|
|
327
|
+
return this.devMethodePlayer.enterMiniPlayer()
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
exitMiniPlayer() {
|
|
331
|
+
return this.devMethodePlayer.exitMiniPlayer()
|
|
332
|
+
}
|
|
333
|
+
|
|
298
334
|
destruct() {
|
|
335
|
+
let _this = this;
|
|
336
|
+
|
|
337
|
+
return new Promise((resolve) => {
|
|
338
|
+
_this.additionalInfoService.remove(this);
|
|
339
|
+
|
|
340
|
+
_this.additionalInfoService = null;
|
|
341
|
+
|
|
342
|
+
this.plyr.destroy(() => {
|
|
343
|
+
_this = undefined;
|
|
344
|
+
resolve(true);
|
|
345
|
+
})
|
|
346
|
+
})
|
|
299
347
|
}
|
|
300
348
|
setDesktopEvents() {
|
|
301
349
|
this.desktopEvents = new LTPlayerEvents.Desktop();
|
|
@@ -42,7 +42,7 @@ export namespace LTPLayerAddInfo {
|
|
|
42
42
|
export class Controller extends LTPlayerAddInfoManager {
|
|
43
43
|
activePlayer: Plyr;
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
setContainer(container: HTMLElement) {
|
|
46
46
|
this.container = container;
|
|
47
47
|
this.setDataContent();
|
|
48
48
|
}
|
|
@@ -61,6 +61,14 @@ export namespace LTPLayerAddInfo {
|
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
setConfig(config: defaultType) {
|
|
65
|
+
Object.keys(config).forEach(item => {
|
|
66
|
+
if (Object.keys(config[item]).length > 0) {
|
|
67
|
+
Object.assign(this.additionalData, {[item] : config[item]})
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
init(player: LTPlayer.PortraitType | LTPlayer.LandscapeType, playerId: number, iconService: IconsService, templateService: TemplateService) {
|
|
65
73
|
|
|
66
74
|
if (Object.keys(this.additionalData).length === 0) {
|
|
@@ -101,7 +109,6 @@ export namespace LTPLayerAddInfo {
|
|
|
101
109
|
|
|
102
110
|
setCurrentPlayerPlay(instance: LTPlayer.PortraitType | LTPlayer.LandscapeType, event: PlyrEvent) {
|
|
103
111
|
this.activePlayer = event.detail.plyr;
|
|
104
|
-
console.log(this.activePlayer.elements.container)
|
|
105
112
|
}
|
|
106
113
|
remove(instance: LTPlayer.LandscapeType | LTPlayer.PortraitType) {
|
|
107
114
|
|
|
@@ -132,7 +139,9 @@ export namespace LTPLayerAddInfo {
|
|
|
132
139
|
|
|
133
140
|
switch (this.controller.device) {
|
|
134
141
|
case 'mobile':
|
|
135
|
-
this.
|
|
142
|
+
this.controller.plyr.on('ready', () => {
|
|
143
|
+
this.mobile();
|
|
144
|
+
})
|
|
136
145
|
break
|
|
137
146
|
case 'desktop':
|
|
138
147
|
this.desktop();
|
|
@@ -176,7 +185,6 @@ export namespace LTPLayerAddInfo {
|
|
|
176
185
|
|
|
177
186
|
|
|
178
187
|
desktop() {
|
|
179
|
-
const playerContainer = this.controller.plyr.elements.container;
|
|
180
188
|
const icons: defaultType = this.controller.iconService.getIconsByComponent('additionalInfo');
|
|
181
189
|
|
|
182
190
|
let templateData: { target: string; icon: any; }[] = [];
|
|
@@ -204,7 +212,6 @@ export namespace LTPLayerAddInfo {
|
|
|
204
212
|
exist: 'true',
|
|
205
213
|
buttons: templateData
|
|
206
214
|
});
|
|
207
|
-
|
|
208
215
|
this.controller.playerInstance.windowService.setEventAddInfo(buttonsTemplate, this.desktopEvents, this.controller);
|
|
209
216
|
}
|
|
210
217
|
}
|
|
@@ -37,12 +37,25 @@ export namespace LTPlayerAdditionalInfo {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const createInformationModal = (info: additionalInformation, key: string) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
|
|
41
|
+
let modalTemplate = null;
|
|
42
|
+
|
|
43
|
+
if (typeof info === 'object') {
|
|
44
|
+
modalTemplate = controller.templateService.getAdditionalInfo({
|
|
45
|
+
desktop : true,
|
|
46
|
+
modal : true,
|
|
47
|
+
id : `${key}-${controller.playerInstance.playerConfig.getPlayerId()}`,
|
|
48
|
+
object_data : true,
|
|
49
|
+
[key] : info
|
|
50
|
+
})
|
|
51
|
+
} else {
|
|
52
|
+
modalTemplate = controller.templateService.getAdditionalInfo({
|
|
53
|
+
desktop : true,
|
|
54
|
+
modal : true,
|
|
55
|
+
id : `${key}-${controller.playerInstance.playerConfig.getPlayerId()}`,
|
|
56
|
+
data : info
|
|
57
|
+
})
|
|
58
|
+
}
|
|
46
59
|
|
|
47
60
|
document.querySelector('body').insertAdjacentHTML("afterend", modalTemplate);
|
|
48
61
|
}
|
|
@@ -104,12 +117,24 @@ export namespace LTPlayerAdditionalInfo {
|
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
const createInformationModal = (info: additionalInformation, key: string) => {
|
|
107
|
-
let modalTemplate =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
120
|
+
let modalTemplate = null;
|
|
121
|
+
|
|
122
|
+
if (typeof info === 'object') {
|
|
123
|
+
modalTemplate = controller.templateService.getAdditionalInfo({
|
|
124
|
+
mobile : true,
|
|
125
|
+
modal : true,
|
|
126
|
+
[controller.device] : true,
|
|
127
|
+
object_data : true,
|
|
128
|
+
[key] : info
|
|
129
|
+
})
|
|
130
|
+
} else {
|
|
131
|
+
modalTemplate = controller.templateService.getAdditionalInfo({
|
|
132
|
+
mobile : true,
|
|
133
|
+
modal : true,
|
|
134
|
+
data : info,
|
|
135
|
+
[controller.device] : true
|
|
136
|
+
})
|
|
137
|
+
}
|
|
113
138
|
|
|
114
139
|
const playerControlsContainer = instance.plyr.elements.controls;
|
|
115
140
|
const modal = playerControlsContainer.querySelector('.player-lt__modal__mobile');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {playerConfigType} from "../../global/types/ModuleTypes";
|
|
2
2
|
import {LTPlayerConfigProcessor} from "./LTPlayerConfigProcessor";
|
|
3
|
+
import {Helper} from "../../services/Helper";
|
|
4
|
+
import Plyr from "plyr";
|
|
3
5
|
export class LTPlayerConfig {
|
|
4
6
|
|
|
5
7
|
private configData: playerConfigType = {
|
|
@@ -27,7 +29,8 @@ export class LTPlayerConfig {
|
|
|
27
29
|
chapters : null,
|
|
28
30
|
playerType: null,
|
|
29
31
|
device : 'desktop',
|
|
30
|
-
observe : false
|
|
32
|
+
observe : false,
|
|
33
|
+
videoObjectFit : false
|
|
31
34
|
}
|
|
32
35
|
processor : LTPlayerConfigProcessor.Map
|
|
33
36
|
|
|
@@ -61,6 +64,38 @@ export class LTPlayerConfig {
|
|
|
61
64
|
})
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
setObjectFit(plyr : Plyr, instanceType : string) {
|
|
68
|
+
|
|
69
|
+
return new Promise(resolve => {
|
|
70
|
+
if (plyr.isHTML5) {
|
|
71
|
+
|
|
72
|
+
const videoTag = plyr.elements.wrapper.querySelector('video');
|
|
73
|
+
|
|
74
|
+
if (videoTag) {
|
|
75
|
+
|
|
76
|
+
videoTag.addEventListener('loadedmetadata', (event)=> {
|
|
77
|
+
|
|
78
|
+
const type = Helper.getVideoOrientation(videoTag.videoWidth, videoTag.videoHeight);
|
|
79
|
+
|
|
80
|
+
if (type === instanceType) {
|
|
81
|
+
this.configData.videoObjectFit = 'cover';
|
|
82
|
+
} else {
|
|
83
|
+
this.configData.videoObjectFit = 'clip';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
resolve(true);
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getObjectFit() {
|
|
96
|
+
return this.configData.videoObjectFit
|
|
97
|
+
}
|
|
98
|
+
|
|
64
99
|
setVersion(version : string | number) {
|
|
65
100
|
|
|
66
101
|
if (typeof version === 'string') {
|
|
@@ -78,6 +113,14 @@ export class LTPlayerConfig {
|
|
|
78
113
|
return this.configData.observe
|
|
79
114
|
}
|
|
80
115
|
|
|
116
|
+
isObserveHeight() {
|
|
117
|
+
return this.configData.observe.height;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
isObserveWidth() {
|
|
121
|
+
return this.configData.observe.width;
|
|
122
|
+
}
|
|
123
|
+
|
|
81
124
|
getDimensions() {
|
|
82
125
|
return this.configData.dimensions
|
|
83
126
|
}
|
|
@@ -207,10 +207,6 @@ export namespace LTPlayerConfigProcessor {
|
|
|
207
207
|
return null
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
if (version === 1) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
210
|
type shareDataConfig = {
|
|
215
211
|
canonicalUrl : string,
|
|
216
212
|
embedUrl : string,
|
|
@@ -223,6 +219,15 @@ export namespace LTPlayerConfigProcessor {
|
|
|
223
219
|
title : undefined
|
|
224
220
|
}
|
|
225
221
|
|
|
222
|
+
if (version === 1) {
|
|
223
|
+
data = {
|
|
224
|
+
canonicalUrl: data.canonical_url ?? null,
|
|
225
|
+
embedUrl: `${window.location.origin}/embed/${data.id}`,
|
|
226
|
+
title: data.title ?? null,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
226
231
|
if (Object.keys(data).length === 0) {
|
|
227
232
|
return;
|
|
228
233
|
}
|
|
@@ -240,7 +245,6 @@ export namespace LTPlayerConfigProcessor {
|
|
|
240
245
|
}
|
|
241
246
|
|
|
242
247
|
return outputData;
|
|
243
|
-
|
|
244
248
|
}
|
|
245
249
|
|
|
246
250
|
static processPlayerContainer(data : Element | defaultType, version : number) {
|
|
@@ -134,14 +134,27 @@ export namespace LTPlayerControlsEvents {
|
|
|
134
134
|
const playIcon = playerContainer.querySelector('.bottom-controller__play-icon');
|
|
135
135
|
const pauseIcon = playerContainer.querySelector('.bottom-controller__pause-icon');
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
if (player.isEmbed) {
|
|
138
|
+
player.embed.getPaused().then((paused: any) => {
|
|
139
|
+
if (paused) {
|
|
140
|
+
pauseIcon.classList.add('d-none');
|
|
141
|
+
playIcon.classList.remove('d-none');
|
|
142
|
+
} else {
|
|
143
|
+
playIcon.classList.add('d-none');
|
|
144
|
+
pauseIcon.classList.remove('d-none');
|
|
145
|
+
}
|
|
146
|
+
})
|
|
141
147
|
} else {
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
if (player.playing) {
|
|
149
|
+
playIcon.classList.add('d-none');
|
|
150
|
+
pauseIcon.classList.remove('d-none');
|
|
151
|
+
} else {
|
|
152
|
+
pauseIcon.classList.add('d-none');
|
|
153
|
+
playIcon.classList.remove('d-none');
|
|
154
|
+
}
|
|
144
155
|
}
|
|
156
|
+
|
|
157
|
+
|
|
145
158
|
}
|
|
146
159
|
}
|
|
147
160
|
|
|
@@ -172,11 +185,12 @@ export namespace LTPlayerControlsEvents {
|
|
|
172
185
|
|
|
173
186
|
|
|
174
187
|
if (!playerControls.classList.contains('plyr__controls-enable')) {
|
|
175
|
-
captions.classList.remove('
|
|
188
|
+
captions.classList.remove('d-none');
|
|
189
|
+
// captions.classList.remove('on-controls-hover');
|
|
176
190
|
return;
|
|
177
191
|
}
|
|
178
|
-
|
|
179
|
-
captions.classList.add('on-controls-hover');
|
|
192
|
+
captions.classList.add('d-none');
|
|
193
|
+
// captions.classList.add('on-controls-hover');
|
|
180
194
|
|
|
181
195
|
}
|
|
182
196
|
showHide(instance: LTPlayer.LandscapeType | LTPlayer.PortraitType) {
|
|
@@ -187,7 +201,9 @@ export namespace LTPlayerControlsEvents {
|
|
|
187
201
|
|
|
188
202
|
|
|
189
203
|
controls.addEventListener('mouseleave', function () {
|
|
190
|
-
|
|
204
|
+
if (!controls.classList.contains('plyr__controls-enable-settings')) {
|
|
205
|
+
controls.classList.remove('plyr__controls-enable')
|
|
206
|
+
}
|
|
191
207
|
})
|
|
192
208
|
}
|
|
193
209
|
|
|
@@ -17,6 +17,12 @@ export class LTPlayerMini {
|
|
|
17
17
|
templateService: TemplateService
|
|
18
18
|
private iconService: IconsService;
|
|
19
19
|
|
|
20
|
+
playerType : string
|
|
21
|
+
|
|
22
|
+
instance : LTPlayer.PortraitType | LTPlayer.LandscapeType
|
|
23
|
+
|
|
24
|
+
observe : ResizeObserver
|
|
25
|
+
|
|
20
26
|
constructor() {
|
|
21
27
|
}
|
|
22
28
|
|
|
@@ -25,14 +31,30 @@ export class LTPlayerMini {
|
|
|
25
31
|
* @param player
|
|
26
32
|
* @param templateService
|
|
27
33
|
* @param iconService
|
|
34
|
+
* @param playerType
|
|
35
|
+
* @param instance
|
|
28
36
|
*/
|
|
29
|
-
init(player: Plyr, templateService: TemplateService, iconService: IconsService) {
|
|
37
|
+
init(player: Plyr, templateService: TemplateService, iconService: IconsService, playerType : string, instance : LTPlayer.LandscapeType | LTPlayer.PortraitType) {
|
|
38
|
+
this.instance = instance;
|
|
30
39
|
this.templateService = templateService;
|
|
31
40
|
this.iconService = iconService;
|
|
32
41
|
this.player = player;
|
|
42
|
+
this.playerType = playerType;
|
|
33
43
|
this.setup();
|
|
34
44
|
}
|
|
35
45
|
|
|
46
|
+
enterMiniPlayer() {
|
|
47
|
+
this.playerContainer.width = this.player.elements.wrapper.getBoundingClientRect().width;
|
|
48
|
+
this.playerContainer.height = this.player.elements.wrapper.getBoundingClientRect().height;
|
|
49
|
+
this.player.elements.wrapper.classList.add('lt-player-mini-enable');
|
|
50
|
+
this.player.elements.wrapper.classList.add(`lt-player-mini-${this.playerType}`)
|
|
51
|
+
this.setBackground(this.player.elements.wrapper);
|
|
52
|
+
this.addMouseHoverControllers();
|
|
53
|
+
this.addPlayPauseEvents();
|
|
54
|
+
this.setSeekBar();
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
/**
|
|
37
59
|
* Setup mini player
|
|
38
60
|
* @private
|
|
@@ -43,15 +65,15 @@ export class LTPlayerMini {
|
|
|
43
65
|
player.on('ready', function () {
|
|
44
66
|
const playerContainer = player.elements.container;
|
|
45
67
|
const playerWrapper = player.elements.wrapper;
|
|
46
|
-
_this.playerContainer.width = playerWrapper.getBoundingClientRect().width;
|
|
47
|
-
_this.playerContainer.height = playerWrapper.getBoundingClientRect().height;
|
|
48
|
-
|
|
49
68
|
const button = playerContainer.querySelector('.mini-player-control');
|
|
50
69
|
|
|
51
70
|
if (button) {
|
|
52
71
|
button.addEventListener('click', function (event) {
|
|
53
72
|
event.preventDefault();
|
|
73
|
+
_this.playerContainer.width = playerContainer.getBoundingClientRect().width;
|
|
74
|
+
_this.playerContainer.height = playerContainer.getBoundingClientRect().height;
|
|
54
75
|
playerWrapper.classList.add('lt-player-mini-enable');
|
|
76
|
+
playerWrapper.classList.add(`lt-player-mini-${_this.playerType}`)
|
|
55
77
|
_this.setBackground(playerWrapper);
|
|
56
78
|
_this.addMouseHoverControllers();
|
|
57
79
|
_this.addPlayPauseEvents();
|
|
@@ -96,7 +118,9 @@ export class LTPlayerMini {
|
|
|
96
118
|
* @param playerWrapper
|
|
97
119
|
*/
|
|
98
120
|
private setBackground(playerWrapper: HTMLElement) {
|
|
121
|
+
|
|
99
122
|
const background = this.templateService.getBackGroundTemplate({logo : this.iconService.getLogo()});
|
|
123
|
+
|
|
100
124
|
const controls = this.templateService.getControlsMiniPlayer({
|
|
101
125
|
mini_player: 'true',
|
|
102
126
|
icons: this.iconService.getIconsByComponent('controls'),
|
|
@@ -104,6 +128,48 @@ export class LTPlayerMini {
|
|
|
104
128
|
|
|
105
129
|
playerWrapper.insertAdjacentHTML("afterend", background);
|
|
106
130
|
playerWrapper.children[0].insertAdjacentHTML("afterend", controls);
|
|
131
|
+
|
|
132
|
+
if (this.instance.playerConfig.getObserve()) {
|
|
133
|
+
if (this.instance.playerConfig.isObserveHeight() !== undefined && !this.instance.playerConfig.isObserveHeight()) {
|
|
134
|
+
this.setObserveBackground();
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
this.setObserveBackground();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
setObserveBackground() {
|
|
143
|
+
|
|
144
|
+
const miniPlayerBackground : HTMLElement = this.player.elements.container.querySelector('.lt-player-mini-player-background');
|
|
145
|
+
|
|
146
|
+
this.observe = new ResizeObserver(response => {
|
|
147
|
+
let documentWidth = response[0].contentRect.width;
|
|
148
|
+
let miniPlayerBackgroundWidth = miniPlayerBackground.getBoundingClientRect().width;
|
|
149
|
+
if (documentWidth >= miniPlayerBackgroundWidth) {
|
|
150
|
+
if (documentWidth > this.playerContainer.width) {
|
|
151
|
+
if (this.player.elements.controls.getBoundingClientRect().height === 103) {
|
|
152
|
+
miniPlayerBackground.style.width = `${this.playerContainer.width}px`;
|
|
153
|
+
miniPlayerBackground.style.height = `${this.playerContainer.height}px`;
|
|
154
|
+
} else {
|
|
155
|
+
miniPlayerBackground.style.width = `${this.player.elements.controls.getBoundingClientRect().width}px`;
|
|
156
|
+
miniPlayerBackground.style.height = `${this.player.elements.controls.getBoundingClientRect().height}px`;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
miniPlayerBackground.style.width = `${this.playerContainer.width}px`;
|
|
160
|
+
let calc = this.playerContainer.height + (response[0].contentRect.width - this.playerContainer.width);
|
|
161
|
+
miniPlayerBackground.style.height = (calc > 100) ? `${calc}px` : this.playerContainer.height;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (documentWidth < miniPlayerBackgroundWidth) {
|
|
165
|
+
miniPlayerBackground.style.width = `${documentWidth}px`;
|
|
166
|
+
let calc = this.playerContainer.height - (this.playerContainer.width - response[0].contentRect.width);
|
|
167
|
+
miniPlayerBackground.style.height = (calc > 100) ? `${calc}px` : this.playerContainer.height;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
this.observe.observe(document.body);
|
|
107
173
|
}
|
|
108
174
|
|
|
109
175
|
/**
|
|
@@ -178,6 +244,7 @@ export class LTPlayerMini {
|
|
|
178
244
|
exitMiniPlayer(player: Plyr) {
|
|
179
245
|
const playerContainer = player.elements.container;
|
|
180
246
|
const exit = playerContainer.querySelector('.lt-player-mini-player-controls__exit');
|
|
247
|
+
let _this = this;
|
|
181
248
|
|
|
182
249
|
if (!exit) {
|
|
183
250
|
return
|
|
@@ -187,7 +254,10 @@ export class LTPlayerMini {
|
|
|
187
254
|
event.preventDefault();
|
|
188
255
|
playerContainer.querySelector('.lt-player-mini-player-controls').remove();
|
|
189
256
|
playerContainer.querySelector('.lt-player-mini-player-background').remove();
|
|
190
|
-
playerContainer.querySelector('.lt-player-mini-enable').classList.remove(
|
|
257
|
+
playerContainer.querySelector('.lt-player-mini-enable').classList.remove(`lt-player-mini-${_this.playerType}`)
|
|
258
|
+
playerContainer.querySelector('.lt-player-mini-enable').classList.remove('lt-player-mini-enable');
|
|
259
|
+
_this.observe.disconnect();
|
|
260
|
+
|
|
191
261
|
})
|
|
192
262
|
}
|
|
193
263
|
|
|
@@ -66,11 +66,11 @@ export class LTPlayerDesktopSettingsControllers implements SettingsControlsInter
|
|
|
66
66
|
|
|
67
67
|
myRange.oninput = function() {
|
|
68
68
|
player.speed = parseFloat(values[rangeInput.value]);
|
|
69
|
-
myValue.innerHTML = values[rangeInput.value]
|
|
69
|
+
myValue.innerHTML = `${values[rangeInput.value]}X`;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
player.speed = parseFloat(String(values[0]));
|
|
73
|
-
myValue.innerHTML = values[0]
|
|
73
|
+
myValue.innerHTML = `${values[0]}X`;
|
|
74
74
|
}
|
|
75
75
|
initSaveButton() {
|
|
76
76
|
|