@profitlich/template-toolkit 2.16.0 → 2.18.0

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;
@@ -87,7 +97,7 @@ export class MuxPlayer {
87
97
  player.setAttribute('data-autoplay', 'true');
88
98
  }
89
99
 
90
- const setPlaying = value => player.parentElement.setAttribute('data-playing', value);
100
+ const setPlaying = value => player.setAttribute('data-playing', value);
91
101
 
92
102
  player.addEventListener('playing', () => setPlaying('true'));
93
103
  player.addEventListener('pause', () => setPlaying('pause'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profitlich/template-toolkit",
3
- "version": "2.16.0",
3
+ "version": "2.18.0",
4
4
  "description": "Shared SCSS layout system, JS utilities, components and build scripts for profitlich template repos",
5
5
  "type": "module",
6
6
  "exports": {