@latest-thinking/lt-player 1.0.9-b → 1.0.9-d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latest-thinking/lt-player",
3
- "version": "1.0.9-b",
3
+ "version": "1.0.9-d",
4
4
  "description": "LT player.",
5
5
  "main": "dist/js/lt-player-main.js",
6
6
  "module": "dist/js/lt-player-main.js",
@@ -16,6 +16,7 @@
16
16
 
17
17
  $lt-font-family-base: "MuseoSans", sans-serif !important;
18
18
 
19
+ $lt-player-font-size-xxs: 10px;
19
20
  $lt-player-font-size-xs: 12px;
20
21
  $lt-player-font-size-sm: 14px;
21
22
  $lt-player-font-size-base: 16px;
@@ -68,11 +68,7 @@
68
68
  }
69
69
 
70
70
  span {
71
- font-size: 10px;
72
- }
73
-
74
- [class="playback-speed--1.25X"] {
75
- font-size: 8px;
71
+ font-size: $lt-player-font-size-xxs;
76
72
  }
77
73
  }
78
74
  }
@@ -344,11 +340,7 @@
344
340
  height: 40px;
345
341
 
346
342
  span {
347
- font-size: 14px;
348
- }
349
-
350
- [class="playback-speed--1.25X"] {
351
- font-size: 9px;
343
+ font-size: $lt-player-font-size-sm;
352
344
  }
353
345
  }
354
346
  }
@@ -24,9 +24,9 @@ export class LTPlayerManager {
24
24
 
25
25
  let domElements: NodeListOf<HTMLElement>;
26
26
 
27
- domElements = document.querySelectorAll(`.${process.env.DEFAULT_DOM_HTML_ELEMENTS}`);
27
+ domElements = document.querySelectorAll(`.${process.env.DEFAULT_DOM_HTML_ELEMENTS}, #${process.env.DEFAULT_DOM_HTML_ELEMENTS}`);
28
28
 
29
- if (domElements.length === 0) {
29
+ if (domElements.length !== 0) {
30
30
  domElements = document.querySelectorAll('[data-lt-player-config]');
31
31
  }
32
32
 
@@ -51,8 +51,9 @@ export class LTPlayerManager {
51
51
  /**
52
52
  * Init player by identifier
53
53
  * @param identifier
54
+ * @param playerConfig
54
55
  */
55
- initByClassOrID(identifier: string) {
56
+ initByClassOrID(identifier: string, playerConfig?: playerConfigType) {
56
57
 
57
58
  if (typeof identifier !== 'string') {
58
59
  console.error('Identifier has another type of');
@@ -69,7 +70,7 @@ export class LTPlayerManager {
69
70
  return;
70
71
  }
71
72
  return new Promise(resolve => {
72
- this.initBySelector(defaultSelector).then( result => {
73
+ this.initBySelector(defaultSelector, playerConfig).then(result => {
73
74
  resolve(result);
74
75
  })
75
76
  })
@@ -79,13 +80,24 @@ export class LTPlayerManager {
79
80
  /**
80
81
  * Init player by HTMLElement selector
81
82
  * @param selector
83
+ * @param playerConfig
82
84
  */
83
- initBySelector(selector: HTMLElement) {
84
- let playerConfig = selector.dataset.ltPlayerConfig;
85
+ initBySelector(selector: HTMLElement, playerConfig?: playerConfigType) {
85
86
 
86
- if (playerConfig !== undefined) {
87
+ let config: playerConfigType | string = selector.dataset.ltPlayerConfig;
87
88
 
88
- const configData = JSON.parse(playerConfig);
89
+ if (!config) {
90
+ config = playerConfig;
91
+ }
92
+
93
+ if (config !== undefined) {
94
+ let configData: playerConfigType;
95
+
96
+ if (typeof config === "string") {
97
+ configData = JSON.parse(config);
98
+ } else {
99
+ configData = config;
100
+ }
89
101
 
90
102
  Object.assign(configData.body, {playerContainer: selector})
91
103
 
@@ -96,13 +108,17 @@ export class LTPlayerManager {
96
108
  })
97
109
  }
98
110
 
99
- console.error(`Lt Player: No "data-lt-player-config" attribute is set on element!`);
100
- console.log(selector)
101
- console.error('Use one of below examples')
102
- console.table({
103
- Example_1: '<div class="lt-player" data-lt-player-config="{config}"> </div>',
111
+ return new Promise((resolve, reject) => {
112
+ console.error(`Lt Player: No "data-lt-player-config" attribute is set on element!`);
113
+ console.log(selector)
114
+ console.error('Use one of below examples')
115
+ console.table({
116
+ Example_1: '<div class="lt-player" data-lt-player-config="{config}"> </div>',
117
+ })
118
+ reject()
104
119
  })
105
- return;
120
+
121
+
106
122
  }
107
123
 
108
124
  /**
@@ -110,25 +126,27 @@ export class LTPlayerManager {
110
126
  * @param playerConfig
111
127
  * @protected
112
128
  */
113
- public initPlayer(playerConfig?: playerConfigType) {
129
+ public initPlayer(playerConfig?: playerConfigType): Promise<any> | null {
114
130
 
115
131
  const setup = new LTPlayerSetup();
116
132
 
117
- return new Promise((resolve, reject) => {
118
- let setupPLayer = setup.init(playerConfig);
119
-
120
- if (setupPLayer) {
121
- setupPLayer.then( result => {
122
- this.players.push(result);
123
- resolve(result);
124
- })
125
- } else {
126
- reject('Player is not setup')
127
- }
128
-
129
- })
130
-
133
+ return new Promise((resolve, reject) => {
134
+ if (!setup.checkIfPlayerExists(playerConfig)) {
135
+ reject('Duplicate player');
136
+ return;
137
+ }
138
+ let setupPLayer = setup.init(playerConfig);
139
+
140
+ if (setupPLayer) {
141
+ setupPLayer.then( result => {
142
+ this.players.push(result);
143
+ resolve(result);
144
+ })
145
+ } else {
146
+ reject('Player is not setup')
147
+ }
131
148
 
149
+ })
132
150
  }
133
151
 
134
152
  /**
@@ -7,8 +7,14 @@ import {LTPLayerAddInfo} from "./addInfo/LTPlayerAddInfoManager";
7
7
  import Plyr from "plyr";
8
8
 
9
9
  export class LTPlayerSetup {
10
+
10
11
  additionalInfoService: LTPLayerAddInfo.Controller;
11
12
 
13
+ checkIfPlayerExists(playerConfig?: playerConfigType): boolean
14
+ {
15
+ return playerConfig.body.playerContainer instanceof HTMLElement;
16
+ }
17
+
12
18
  init(playerConfig?: playerConfigType): Promise<any> {
13
19
 
14
20
  Helper.setDebugEvent('Start init player', 'info');
@@ -119,8 +119,10 @@ export class LTPlayerDesktopSettingsControllers implements SettingsControlsInter
119
119
  }
120
120
 
121
121
  plyr.speed = playSpeed;
122
- speedSpan.innerHTML = playSpeed + "X";
122
+ const displaySpeed = Math.floor(playSpeed * 10) / 10;
123
+ speedSpan.innerHTML = displaySpeed + "X";
123
124
  speedSpan.className = '';
125
+ console.log(playSpeed.toPrecision(2));
124
126
  speedSpan.classList.add('playback-speed--' + playSpeed + 'X');
125
127
 
126
128
  instance.playerControl.mobileEvents.showControls(instance);
@@ -191,7 +191,8 @@ export class LTPlayerMobileSettingsControllers implements SettingsControlsInterf
191
191
  }
192
192
 
193
193
  plyr.speed = playSpeed;
194
- speedSpan.innerHTML = playSpeed + "X";
194
+ const displaySpeed = Math.floor(playSpeed * 10) / 10;
195
+ speedSpan.innerHTML = displaySpeed + "X";
195
196
  speedSpan.className = '';
196
197
  speedSpan.classList.add('playback-speed--' + playSpeed + 'X');
197
198