@profitlich/template-toolkit 2.17.0 → 2.18.1

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.
@@ -5,12 +5,12 @@ export class MuxPlayer {
5
5
  #lazyLoadObserver;
6
6
  #playPauseObserver;
7
7
  #loop;
8
- #resolution;
8
+ #noLowRes;
9
9
  #onPlayerCreated;
10
10
 
11
- constructor({ loop = false, resolution = '1080p', onPlayerCreated = null } = {}) {
11
+ constructor({ loop = false, noLowRes = false, onPlayerCreated = null } = {}) {
12
12
  this.#loop = loop;
13
- this.#resolution = resolution;
13
+ this.#noLowRes = noLowRes;
14
14
  this.#onPlayerCreated = onPlayerCreated;
15
15
  this.#lazyLoadObserver = new IntersectionObserver(this.#handleLazyLoad.bind(this));
16
16
  this.#playPauseObserver = new IntersectionObserver(this.#handlePlayPause.bind(this));
@@ -71,7 +71,17 @@ export class MuxPlayer {
71
71
  player.playsInline = true;
72
72
  player.style.aspectRatio = aspectRatio;
73
73
  player.thumbnailTime = 0;
74
- player.minResolution = this.#resolution;
74
+ if (this.#noLowRes) {
75
+ const cssWidth = container.getBoundingClientRect().width;
76
+ const physicalWidth = cssWidth * window.devicePixelRatio;
77
+ const [arW, arH] = aspectRatio.split('/').map(s => parseFloat(s.trim()));
78
+ const physicalHeight = physicalWidth * (arH / arW);
79
+ const tiers = [
80
+ [270, '270p'], [360, '360p'], [480, '480p'], [540, '540p'],
81
+ [720, '720p'], [1080, '1080p'], [1440, '1440p'], [2160, '2160p'],
82
+ ];
83
+ player.minResolution = (tiers.find(([px]) => physicalHeight <= px) ?? [, '2160p'])[1];
84
+ }
75
85
 
76
86
  if (container.dataset.accentColor) {
77
87
  player.accentColor = container.dataset.accentColor;
@@ -93,6 +103,13 @@ export class MuxPlayer {
93
103
  player.addEventListener('pause', () => setPlaying('pause'));
94
104
  player.addEventListener('ended', () => setPlaying('ended'));
95
105
 
106
+ console.log(
107
+ 'Toolkit Video',
108
+ 'width:',container.getBoundingClientRect().width,
109
+ 'height:', container.getBoundingClientRect().height,
110
+ 'aspectRatio:', aspectRatio
111
+ );
112
+
96
113
  container.replaceWith(player);
97
114
  setPlaying('false');
98
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profitlich/template-toolkit",
3
- "version": "2.17.0",
3
+ "version": "2.18.1",
4
4
  "description": "Shared SCSS layout system, JS utilities, components and build scripts for profitlich template repos",
5
5
  "type": "module",
6
6
  "exports": {