@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
|
-
#
|
|
8
|
+
#noLowRes;
|
|
9
9
|
#onPlayerCreated;
|
|
10
10
|
|
|
11
|
-
constructor({ loop = false,
|
|
11
|
+
constructor({ loop = false, noLowRes = false, onPlayerCreated = null } = {}) {
|
|
12
12
|
this.#loop = loop;
|
|
13
|
-
this.#
|
|
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
|
-
|
|
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