Skip to content

Commit bb5b09c

Browse files
committed
Fix quality selector labels for portrait videos
1 parent 58d7832 commit bb5b09c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/plugin.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@ class HlsQualitySelectorPlugin {
110110
const levelItems = [];
111111

112112
for (let i = 0; i < levels.length; ++i) {
113-
if (!levels[i].height) {
113+
const {width, height} = levels[i];
114+
const pixels = width > height ? height : width;
115+
116+
if (!pixels) {
114117
continue;
115118
}
119+
116120
if (!levelItems.filter(_existingItem => {
117-
return _existingItem.item && _existingItem.item.value === levels[i].height;
121+
return _existingItem.item && _existingItem.item.value === pixels;
118122
}).length) {
119123
const levelItem = this.getQualityMenuItem.call(this, {
120-
label: levels[i].height + 'p',
121-
value: levels[i].height
124+
label: pixels + 'p',
125+
value: pixels
122126
});
123127

124128
levelItems.push(levelItem);
@@ -154,24 +158,25 @@ class HlsQualitySelectorPlugin {
154158
}
155159

156160
/**
157-
* Sets quality (based on media height)
161+
* Sets quality (based on media short side)
158162
*
159-
* @param {number} height - A number representing HLS playlist.
163+
* @param {number} quality - A number representing HLS playlist.
160164
*/
161-
setQuality(height) {
165+
setQuality(quality) {
162166
const qualityList = this.player.qualityLevels();
163167

164168
// Set quality on plugin
165-
this._currentQuality = height;
169+
this._currentQuality = quality;
166170

167171
if (this.config.displayCurrentQuality) {
168-
this.setButtonInnerText(height === 'auto' ? height : `${height}p`);
172+
this.setButtonInnerText(quality === 'auto' ? quality : `${quality}p`);
169173
}
170174

171175
for (let i = 0; i < qualityList.length; ++i) {
172-
const quality = qualityList[i];
176+
const {width, height} = qualityList[i];
177+
const pixels = width > height ? height : width;
173178

174-
quality.enabled = (quality.height === height || height === 'auto');
179+
qualityList[i].enabled = (pixels === quality || quality === 'auto');
175180
}
176181
this._qualityButton.unpressButton();
177182
}

0 commit comments

Comments
 (0)