@latest-thinking/lt-player 1.1.0-k → 1.1.0-m

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.
@@ -220,6 +220,11 @@ export namespace LTPlayerControlsEvents {
220
220
  const controls = instance.plyr.elements.controls;
221
221
  const eventsInstance = this;
222
222
 
223
+ if (instance.playerConfig.isAlwaysDisplayControls()) {
224
+ controls.classList.add('plyr__controls-enable');
225
+ return;
226
+ }
227
+
223
228
  controls.addEventListener('mouseover', function () {
224
229
  controls.classList.add('plyr__controls-enable');
225
230
  eventsInstance.common.subtitlesHide(instance);
@@ -581,7 +586,13 @@ export namespace LTPlayerControlsEvents {
581
586
  clearTimeout(this.controlsTimeOut);
582
587
  }
583
588
 
584
- this.hideControls(instance, false);
589
+
590
+ if (!instance.playerConfig.isAlwaysDisplayControls()) {
591
+ this.hideControls(instance, false);
592
+ return;
593
+ }
594
+
595
+
585
596
  }
586
597
 
587
598
  hideControls(instance: LTPlayer.PortraitType | LTPlayer.LandscapeType, now: boolean) {
@@ -656,7 +667,9 @@ export namespace LTPlayerControlsEvents {
656
667
  const selectors = common.backwardRewind.getSelectors(instance);
657
668
 
658
669
  const singleTapAction = () => {
659
- instance.playerControl.mobileEvents.hideControls(instance, true);
670
+ if (!instance.playerConfig.isAlwaysDisplayControls()) {
671
+ instance.playerControl.mobileEvents.hideControls(instance, true);
672
+ }
660
673
  }
661
674
 
662
675
  if (selectors.forwardArea) {
@@ -27,26 +27,25 @@ export class LTPlayerCommon {
27
27
 
28
28
  instance.plyr.speed = 1;
29
29
 
30
- instance.plyr.toggleCaptions(false);
31
- return;
32
-
33
- //
34
- // if (instance.plyr.isEmbed) {
35
- // instance.plyr.embed.getTextTracks().then( (response: string | any[]) => {
36
- // if (response.length !== 0) {
37
- // instance.plyr.toggleCaptions(true);
38
- // } else {
39
- // instance.plyr.toggleCaptions(false);
40
- // }
41
- // })
42
- // } else {
43
- //
44
- // let checkCaptions = (instance.plyr as plyr).captions;
45
- //
46
- // if (checkCaptions.currentTrack >= 0) {
47
- // instance.plyr.toggleCaptions(true);
48
- // }
49
- // }
30
+ if (!instance.plyr.isEmbed) {
31
+ let checkCaptions = (instance.plyr as plyr).captions;
32
+
33
+ if (checkCaptions.currentTrack >= 0) {
34
+ instance.plyr.toggleCaptions(true);
35
+ return;
36
+ }
37
+ instance.plyr.toggleCaptions(false);
38
+ return;
39
+ }
40
+
41
+ instance.plyr.embed.getTextTracks().then( (response: string | any[]) => {
42
+ if (response.length !== 0) {
43
+ instance.plyr.toggleCaptions(true);
44
+ return;
45
+ }
46
+ instance.plyr.toggleCaptions(false);
47
+
48
+ })
50
49
  }
51
50
  removeDesktopPlyrEvents() {
52
51
  let plyrInstance = this.plyr as Plyr as Plyr & { eventListeners: Array<any> }
@@ -175,4 +174,21 @@ export class LTPlayerCommon {
175
174
  }
176
175
  }
177
176
 
177
+ setCustomSubtitles(controls: HTMLElement, event: Plyr.PlyrEvent )
178
+ {
179
+ const eventPlayer: any = event.detail.plyr;
180
+
181
+ const customSubtitlesElement = controls.querySelector('.lt-player-custom-captions');
182
+ const spanElement = customSubtitlesElement.querySelector('span');
183
+
184
+ if (!spanElement) {
185
+ return;
186
+ }
187
+
188
+ if (eventPlayer.captions.currentTrackNode.activeCues.length > 0) {
189
+ spanElement.innerHTML = eventPlayer.captions.currentTrackNode.activeCues[0].text;
190
+ } else {
191
+ spanElement.innerHTML = ''; // Clear previous captions
192
+ }
193
+ }
178
194
  }
@@ -25,6 +25,7 @@ export class LTPlayerDesktop extends LTPlayerCommon implements EventsInterfaces
25
25
  this.plyrOnPlay();
26
26
  this.plyrOnPause();
27
27
  this.plyrOnSeek();
28
+ this.plyrOnCueChange();
28
29
  }
29
30
 
30
31
  plyrOnSeek():void {
@@ -205,4 +206,13 @@ export class LTPlayerDesktop extends LTPlayerCommon implements EventsInterfaces
205
206
  })
206
207
  }
207
208
 
209
+ plyrOnCueChange() {
210
+ let common = this;
211
+ let instance: LTPlayer.PortraitType | LTPlayer.LandscapeType = this.player;
212
+ let plyr: Plyr = this.plyr;
213
+
214
+ plyr.on('cuechange', function LTPlayerDesktopTimeUpdate(event) {
215
+ common.setCustomSubtitles(plyr.elements.controls, event)
216
+ })
217
+ }
208
218
  }
@@ -25,6 +25,7 @@ export class LTPlayerMobile extends LTPlayerCommon implements EventsInterfaces {
25
25
  this.plyrOnPlay();
26
26
  this.plyrOnPause();
27
27
  this.plyrOnSeek();
28
+ this.plyrOnCueChange()
28
29
  }
29
30
 
30
31
  plyrOnSeek():void {
@@ -228,4 +229,14 @@ export class LTPlayerMobile extends LTPlayerCommon implements EventsInterfaces {
228
229
  return undefined;
229
230
  }
230
231
 
232
+ plyrOnCueChange() {
233
+ let common = this;
234
+ let instance: LTPlayer.PortraitType | LTPlayer.LandscapeType = this.player;
235
+ let plyr: Plyr = this.plyr;
236
+
237
+ plyr.on('cuechange', function LTPlayerDesktopTimeUpdate(event) {
238
+ common.setCustomSubtitles(plyr.elements.controls, event)
239
+ })
240
+ }
241
+
231
242
  }
@@ -31,6 +31,7 @@
31
31
  </div>
32
32
  </div>
33
33
  <div class="lt-player-notification landscape">
34
+ <div class="lt-player-custom-captions"><span></span></div>
34
35
  <!-- <div class="lt-player-video-content">-->
35
36
  <!-- <div class="content__body">-->
36
37
  <!-- <h4 class="poster-title">{{videoParagraph}}</h4>-->
@@ -38,6 +39,7 @@
38
39
  <!-- </div>-->
39
40
  <!-- </div>-->
40
41
  <div class="lt-player-notification__notification-button-state landscape">
42
+
41
43
  <div class="player-state">
42
44
  <img class="player-state__icon filter" src="" alt="">
43
45
  </div>
@@ -166,6 +168,7 @@
166
168
  {{#mobile}}
167
169
  <div class="plyr__controls__mobile-background d-none">
168
170
  <div class="lt-player-notification portrait">
171
+ <div class="lt-player-custom-captions"><span></span></div>
169
172
  <div class="lt-player-rewind-area">
170
173
  </div>
171
174
  <div class="lt-player-rewind lt-player-notify">
@@ -229,6 +232,7 @@
229
232
  </div>
230
233
  </div>
231
234
  <div class="lt-player-notification portrait">
235
+ <div class="lt-player-custom-captions"><span></span></div>
232
236
  <div class="lt-player-notification__notification-button-state portrait">
233
237
  <div class="player-state">
234
238
  <img class="player-state__icon filter" src="" alt="">
@@ -348,6 +352,7 @@
348
352
  {{#mobile}}
349
353
  <div class="plyr__controls__mobile-background d-none">
350
354
  <div class="lt-player-notification portrait">
355
+ <div class="lt-player-custom-captions"><span></span></div>
351
356
  <div class="lt-player-rewind-area">
352
357
  </div>
353
358
  <div class="lt-player-rewind lt-player-notify">