@latest-thinking/lt-player 1.0.5 → 1.0.6
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 +123 -100
- 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 -8
- package/src/components/LTPlayerType.ts +84 -34
- package/src/components/addInfo/LTPlayerAddInfoManager.ts +12 -5
- package/src/components/addInfo/LTPlayerAdditionalInfoEvents.ts +37 -12
- package/src/components/config/LTPlayerConfig.ts +29 -0
- 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 +2 -5
- package/src/components/events/LTPlayerDesktop.ts +25 -2
- package/src/components/events/LTPlayerMobile.ts +25 -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/LTPlayerShareEvents.ts +66 -3
- package/src/global/controllers/LTPlayerController.ts +2 -0
- 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 +69 -69
|
@@ -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
|
}
|
|
@@ -120,7 +120,7 @@ export namespace LTPlayer {
|
|
|
120
120
|
|
|
121
121
|
Object.assign(playerSettings, this.playerConfig.getDefaultConfigItems());
|
|
122
122
|
|
|
123
|
-
Object.assign(playerSettings, {
|
|
123
|
+
Object.assign(playerSettings, {ratio : '9:16'});
|
|
124
124
|
|
|
125
125
|
if (this.playerConfig.getFullscreenMode()) {
|
|
126
126
|
Object.assign(playerSettings, this.playerConfig.getFullscreenMode());
|
|
@@ -128,7 +128,15 @@ export namespace LTPlayer {
|
|
|
128
128
|
|
|
129
129
|
const element = this.playerConfig.getPlayerElementContainer().querySelector('.embed_player');
|
|
130
130
|
|
|
131
|
-
const player = new Plyr(element, playerSettings)
|
|
131
|
+
const player = new Plyr(element, playerSettings);
|
|
132
|
+
|
|
133
|
+
this.playerConfig.setObjectFit(player, 'portrait');
|
|
134
|
+
|
|
135
|
+
this.windowService.init(this);
|
|
136
|
+
|
|
137
|
+
this.plyr = player;
|
|
138
|
+
|
|
139
|
+
this.posterManager.init(this);
|
|
132
140
|
|
|
133
141
|
const chapters = this.playerConfig.getChapters();
|
|
134
142
|
|
|
@@ -136,18 +144,14 @@ export namespace LTPlayer {
|
|
|
136
144
|
this.playerControl.initChapters(this.playerConfig.getChapters());
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
this.
|
|
140
|
-
|
|
141
|
-
this.devMethodePlayer = new LTPlayerDevMethode.Player(player);
|
|
142
|
-
|
|
143
|
-
this.posterManager.init(this);
|
|
147
|
+
this.devMethodePlayer = new LTPlayerDevMethode.Player(this);
|
|
144
148
|
|
|
145
149
|
if (this.playerConfig.getShareData()) {
|
|
146
150
|
this.share.init(this);
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
if (this.playerConfig.getDevice() !== 'mobile') {
|
|
150
|
-
this.miniPlayer.init(player, this.templateService, this.iconService);
|
|
154
|
+
this.miniPlayer.init(player, this.templateService, this.iconService, this.playerConfig.getPlayerType(), this);
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
|
|
@@ -167,6 +171,13 @@ export namespace LTPlayer {
|
|
|
167
171
|
return this.devMethodePreload;
|
|
168
172
|
}
|
|
169
173
|
|
|
174
|
+
enterMiniPlayer() {
|
|
175
|
+
return this.devMethodePlayer.enterMiniPlayer()
|
|
176
|
+
}
|
|
177
|
+
exitMiniPlayer() {
|
|
178
|
+
return this.devMethodePlayer.exitMiniPlayer()
|
|
179
|
+
}
|
|
180
|
+
|
|
170
181
|
destruct() {
|
|
171
182
|
let _this = this;
|
|
172
183
|
|
|
@@ -210,8 +221,14 @@ export namespace LTPlayer {
|
|
|
210
221
|
|
|
211
222
|
this.miniPlayer = new LTPlayerMini();
|
|
212
223
|
this.setPlayerConfig(configData.body, configData.version);
|
|
213
|
-
this.initPoster(configData.body);
|
|
214
224
|
this.initPlayer();
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
if (Helper.checkIsHls(this.playerConfig.getVideoUrl().videoUrl)){
|
|
228
|
+
this.hls = new LTPlayerHls(this, undefined);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
215
232
|
this.setEvents();
|
|
216
233
|
|
|
217
234
|
return true;
|
|
@@ -239,7 +256,7 @@ export namespace LTPlayer {
|
|
|
239
256
|
|
|
240
257
|
Object.assign(playerSettings, this.playerConfig.getDefaultConfigItems());
|
|
241
258
|
|
|
242
|
-
Object.assign(playerSettings, {
|
|
259
|
+
Object.assign(playerSettings, {ratio : '16:9'});
|
|
243
260
|
|
|
244
261
|
if (this.playerConfig.getFullscreenMode()) {
|
|
245
262
|
Object.assign(playerSettings, this.playerConfig.getFullscreenMode());
|
|
@@ -249,24 +266,28 @@ export namespace LTPlayer {
|
|
|
249
266
|
|
|
250
267
|
const player = new Plyr(element, playerSettings);
|
|
251
268
|
|
|
269
|
+
this.playerConfig.setObjectFit(player, 'landscape');
|
|
270
|
+
|
|
271
|
+
this.windowService.init(this);
|
|
272
|
+
|
|
273
|
+
this.plyr = player;
|
|
274
|
+
|
|
275
|
+
this.posterManager.init(this);
|
|
276
|
+
|
|
252
277
|
const chapters = this.playerConfig.getChapters();
|
|
253
278
|
|
|
254
279
|
if (chapters) {
|
|
255
280
|
this.playerControl.initChapters(this.playerConfig.getChapters());
|
|
256
281
|
}
|
|
257
282
|
|
|
258
|
-
this.
|
|
259
|
-
|
|
260
|
-
this.devMethodePlayer = new LTPlayerDevMethode.Player(player);
|
|
261
|
-
|
|
262
|
-
this.posterManager.init(this);
|
|
283
|
+
this.devMethodePlayer = new LTPlayerDevMethode.Player(this);
|
|
263
284
|
|
|
264
285
|
if (this.playerConfig.getShareData()) {
|
|
265
286
|
this.share.init(this);
|
|
266
287
|
}
|
|
267
288
|
|
|
268
289
|
if (this.playerConfig.getDevice() !== 'mobile') {
|
|
269
|
-
this.miniPlayer.init(player, this.templateService, this.iconService);
|
|
290
|
+
this.miniPlayer.init(player, this.templateService, this.iconService, this.playerConfig.getPlayerType(), this);
|
|
270
291
|
}
|
|
271
292
|
}
|
|
272
293
|
|
|
@@ -279,13 +300,6 @@ export namespace LTPlayer {
|
|
|
279
300
|
playerContainer.innerHTML = this.templateService.getTemplateByType(config);
|
|
280
301
|
}
|
|
281
302
|
|
|
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
303
|
private setPlayerConfig(configData: playerConfigType, version: string | number) {
|
|
290
304
|
this.playerConfig = new LTPlayerConfig(version);
|
|
291
305
|
this.playerConfig.mapConfigData(configData);
|
|
@@ -295,7 +309,43 @@ export namespace LTPlayer {
|
|
|
295
309
|
return this.plyr;
|
|
296
310
|
}
|
|
297
311
|
|
|
312
|
+
play() {
|
|
313
|
+
this.devMethodePlayer.play();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
pause() {
|
|
317
|
+
this.devMethodePlayer.pause();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
stop() {
|
|
321
|
+
this.devMethodePlayer.stop();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
preload() {
|
|
325
|
+
return this.devMethodePreload;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
enterMiniPlayer() {
|
|
329
|
+
return this.devMethodePlayer.enterMiniPlayer()
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
exitMiniPlayer() {
|
|
333
|
+
return this.devMethodePlayer.exitMiniPlayer()
|
|
334
|
+
}
|
|
335
|
+
|
|
298
336
|
destruct() {
|
|
337
|
+
let _this = this;
|
|
338
|
+
|
|
339
|
+
return new Promise((resolve) => {
|
|
340
|
+
_this.additionalInfoService.remove(this);
|
|
341
|
+
|
|
342
|
+
_this.additionalInfoService = null;
|
|
343
|
+
|
|
344
|
+
this.plyr.destroy(() => {
|
|
345
|
+
_this = undefined;
|
|
346
|
+
resolve(true);
|
|
347
|
+
})
|
|
348
|
+
})
|
|
299
349
|
}
|
|
300
350
|
setDesktopEvents() {
|
|
301
351
|
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 = {
|
|
@@ -61,6 +63,25 @@ export class LTPlayerConfig {
|
|
|
61
63
|
})
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
setObjectFit(plyr : Plyr, instanceType : string) {
|
|
67
|
+
if (plyr.isHTML5) {
|
|
68
|
+
|
|
69
|
+
const videoTag = plyr.elements.wrapper.querySelector('video');
|
|
70
|
+
|
|
71
|
+
if (videoTag) {
|
|
72
|
+
|
|
73
|
+
videoTag.addEventListener('loadedmetadata', (event)=> {
|
|
74
|
+
|
|
75
|
+
const type = Helper.getVideoOrientation(videoTag.videoWidth, videoTag.videoHeight);
|
|
76
|
+
|
|
77
|
+
if (type === instanceType) {
|
|
78
|
+
videoTag.style.objectFit = 'cover';
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
64
85
|
setVersion(version : string | number) {
|
|
65
86
|
|
|
66
87
|
if (typeof version === 'string') {
|
|
@@ -78,6 +99,14 @@ export class LTPlayerConfig {
|
|
|
78
99
|
return this.configData.observe
|
|
79
100
|
}
|
|
80
101
|
|
|
102
|
+
isObserveHeight() {
|
|
103
|
+
return this.configData.observe.height;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
isObserveWidth() {
|
|
107
|
+
return this.configData.observe.width;
|
|
108
|
+
}
|
|
109
|
+
|
|
81
110
|
getDimensions() {
|
|
82
111
|
return this.configData.dimensions
|
|
83
112
|
}
|
|
@@ -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
|
|
|
@@ -22,7 +22,7 @@ export class LTPlayerMobileSettingsControllers implements SettingsControlsInterf
|
|
|
22
22
|
setButtonSpeed() {
|
|
23
23
|
let playerControlsContainer = this.settingsInstance.playerInstance.plyr.elements.controls;
|
|
24
24
|
let playerSpeedButton = playerControlsContainer.querySelector('.plyr__controls_speed-button');
|
|
25
|
-
playerSpeedButton.innerHTML = `${this.settingsInstance.playerInstance.plyr.speed}`;
|
|
25
|
+
playerSpeedButton.innerHTML = `${this.settingsInstance.playerInstance.plyr.speed}X`;
|
|
26
26
|
let plyr = this.settingsInstance.playerInstance.plyr;
|
|
27
27
|
let instance = this.settingsInstance.playerInstance;
|
|
28
28
|
|
|
@@ -34,19 +34,19 @@ export class LTPlayerMobileSettingsControllers implements SettingsControlsInterf
|
|
|
34
34
|
let playSpeed = plyr.speed + 0.25;
|
|
35
35
|
|
|
36
36
|
if (playSpeed > 2) {
|
|
37
|
-
playerSpeedButton.innerHTML =
|
|
37
|
+
playerSpeedButton.innerHTML = `1x`;
|
|
38
38
|
plyr.speed = 1;
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (playSpeed === 1.75) {
|
|
43
43
|
plyr.speed = playSpeed + 0.25
|
|
44
|
-
playerSpeedButton.innerHTML = `${playSpeed + 0.25}`;
|
|
44
|
+
playerSpeedButton.innerHTML = `${playSpeed + 0.25}X`;
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
plyr.speed = playSpeed;
|
|
49
|
-
playerSpeedButton.innerHTML = `${playSpeed}`;
|
|
49
|
+
playerSpeedButton.innerHTML = `${playSpeed}X`;
|
|
50
50
|
|
|
51
51
|
instance.playerControl.mobileEvents.showControls(instance);
|
|
52
52
|
})
|