@latest-thinking/lt-player 1.0.5-e → 1.0.5-g

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.
@@ -31,29 +31,43 @@ export class LTPlayerPoster {
31
31
 
32
32
 
33
33
  setImage() {
34
- return new Promise((resolve, reject) => {
35
- const posterImageBody: HTMLElement = this.plyr.elements.container.querySelector('.lt-player__poster__image-body');
36
-
37
- if (posterImageBody) {
38
- const imageTag = document.createElement('img');
39
- imageTag.classList.add('lt-player__poster__img--set-custom');
40
- imageTag.src = this.config.getPosterImage();
41
-
42
- imageTag.onload = function LTPlayerLoadPosterImage() {
43
- posterImageBody.append(imageTag);
44
- resolve(true);
45
- }
46
-
47
- imageTag.onerror = function LTPlayerLoadPosterImageError() {
48
- reject(true);
49
- }
34
+ const customImageSelector = this.plyr.elements.container.querySelector('.lt-player__poster__img--set-custom');
35
+ const defaultImageSelector = this.plyr.elements.container.querySelector('.lt-player__poster__img__set-default');
36
+
37
+ const checkImage = (imageUrl: string, callback: (arg0: boolean) => void) => {
38
+ let img = new Image();
39
+
40
+ img.onerror = function() {
41
+ callback(false);
42
+ };
43
+
44
+ img.onload = function() {
45
+ callback(true);
46
+ };
47
+
48
+ img.src = imageUrl;
49
+ }
50
+
51
+
52
+ const setDefault = () => {
53
+ if (defaultImageSelector) {
54
+ defaultImageSelector.classList.remove('d-none');
50
55
  }
51
- })
52
- }
56
+ }
53
57
 
54
- removeDefaultImage() {
55
- const posterImage: HTMLElement = this.plyr.elements.container.querySelector('.lt-player__poster__img');
56
- posterImage.classList.add('d-none');
57
- }
58
58
 
59
+ if (this.config.getPosterImage()) {
60
+ if (customImageSelector) {
61
+ checkImage(this.config.getPosterImage(), function (exist) {
62
+ if (!exist) {
63
+ setDefault();
64
+ } else {
65
+ customImageSelector.classList.remove('d-none');
66
+ }
67
+ })
68
+ }
69
+ } else {
70
+ setDefault()
71
+ }
72
+ }
59
73
  }
@@ -128,13 +128,13 @@ export namespace LTPlayerPosterEvents {
128
128
  * Remove Onload Poster from player
129
129
  */
130
130
  onload(instance: LTPlayer.PortraitType | LTPlayer.LandscapeType) {
131
- const playerElementContainer = instance.playerConfig.getPlayerElementContainer();
132
- const playerOnloadPosterSelector = playerElementContainer.parentElement.querySelector('.lt-player-onload-poster');
133
-
134
- if (playerOnloadPosterSelector) {
135
- playerElementContainer.classList.remove('d-none');
136
- playerElementContainer.parentElement.querySelector('.lt-player-onload-poster').remove();
137
- }
131
+ // const playerElementContainer = instance.playerConfig.getPlayerElementContainer();
132
+ // const playerOnloadPosterSelector = playerElementContainer.parentElement.querySelector('.lt-player-onload-poster');
133
+ //
134
+ // if (playerOnloadPosterSelector) {
135
+ // // playerElementContainer.classList.remove('d-none');
136
+ // playerElementContainer.parentElement.querySelector('.lt-player-onload-poster').remove();
137
+ // }
138
138
  }
139
139
 
140
140
  showControls(instance: LTPlayer.PortraitType | LTPlayer.LandscapeType) {
@@ -23,23 +23,16 @@ export class LTPlayerPosterManager {
23
23
  }
24
24
 
25
25
  init(instance: LTPlayer.LandscapeType | LTPlayer.PortraitType) {
26
+
26
27
  this.instance = instance;
27
28
  this.playerConfig = instance.playerConfig;
28
29
  this.templateService = instance.templateService;
29
30
  this.iconService = instance.iconService;
30
31
 
31
32
  this.poster = new LTPlayerPoster(this.instance.plyr, this.templateService, this.playerConfig, this.iconService);
32
- this.poster.setTemplate();
33
33
 
34
- if (this.playerConfig.getPosterImage()) {
35
- this.poster.setImage().then(
36
- result => {
37
- this.poster.removeDefaultImage();
38
- if (this.playerConfig.getPreload()) {
39
- this.initPreload();
40
- }
41
- });
42
- }
34
+ this.poster.setTemplate();
35
+ this.poster.setImage();
43
36
  if (this.playerConfig.getPreload()) {
44
37
  this.initPreload();
45
38
  }
@@ -282,6 +282,7 @@ export class ResizeService {
282
282
  setHeight();
283
283
  }
284
284
  } else {
285
+
285
286
  setWidth();
286
287
 
287
288
  if (version !== 1) {
@@ -31,14 +31,14 @@
31
31
  </div>
32
32
  </div>
33
33
  </div>
34
- <div class="lt-player-notification">
34
+ <div class="lt-player-notification landscape">
35
35
  <!-- <div class="lt-player-video-content">-->
36
36
  <!-- <div class="content__body">-->
37
37
  <!-- <h4 class="poster-title">{{videoParagraph}}</h4>-->
38
38
  <!-- <p class="poster-paragraph">{{videoTitle}}</p>-->
39
39
  <!-- </div>-->
40
40
  <!-- </div>-->
41
- <div class="lt-player-notification__notification-button-state">
41
+ <div class="lt-player-notification__notification-button-state landscape">
42
42
  <div class="player-state">
43
43
  <img class="player-state__icon filter" src="" alt="">
44
44
  </div>
@@ -167,7 +167,7 @@
167
167
  </div>
168
168
  {{#mobile}}
169
169
  <div class="plyr__controls__mobile-background d-none">
170
- <div class="lt-player-notification">
170
+ <div class="lt-player-notification portrait">
171
171
  <div class="lt-player-rewind-area">
172
172
  </div>
173
173
  <div class="lt-player-rewind lt-player-notify">
@@ -222,8 +222,8 @@
222
222
  </div>
223
223
  </div>
224
224
  </div>
225
- <div class="lt-player-notification">
226
- <div class="lt-player-notification__notification-button-state">
225
+ <div class="lt-player-notification portrait">
226
+ <div class="lt-player-notification__notification-button-state portrait">
227
227
  <div class="player-state">
228
228
  <img class="player-state__icon filter" src="" alt="">
229
229
  </div>
@@ -334,7 +334,7 @@
334
334
  </div>
335
335
  {{#mobile}}
336
336
  <div class="plyr__controls__mobile-background d-none">
337
- <div class="lt-player-notification">
337
+ <div class="lt-player-notification portrait">
338
338
  <div class="lt-player-rewind-area">
339
339
  </div>
340
340
  <div class="lt-player-rewind lt-player-notify">
@@ -1,6 +1,7 @@
1
1
  <div class="lt-player__poster">
2
2
  <div class="lt-player__poster__image-body lt-player__poster__background__grey" >
3
- <img class="lt-player__poster__img lt-player__poster__img__set-default" alt="" src="{{logoBig}}">
3
+ <img class="lt-player__poster__img lt-player__poster__img__set-default d-none" alt="" src="{{logoBig}}">
4
+ <img class="lt-player__poster__img--set-custom d-none" alt="" src="{{config.configData.posterImage}}">
4
5
  </div>
5
6
  <div class="lt-player__poster__body">
6
7
  <div class="content">