Skip to content

Commit

Permalink
fix(UI): Fix resolution selection on src=
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jun 28, 2023
1 parent 9fffcb9 commit f5f164c
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions ui/resolution_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
goog.provide('shaka.ui.ResolutionSelection');

goog.require('goog.asserts');
goog.require('shaka.Player');
goog.require('shaka.ui.Controls');
goog.require('shaka.ui.Enums');
goog.require('shaka.ui.Locales');
Expand Down Expand Up @@ -119,25 +120,30 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
const abrEnabled = this.player.getConfiguration().abr.enabled;

// Add new ones
for (const track of tracks) {
const button = shaka.util.Dom.createButton();
button.classList.add('explicit-resolution');
this.eventManager.listen(button, 'click',
() => this.onTrackSelected_(track));

const span = shaka.util.Dom.createHTMLElement('span');
span.textContent = this.player.isAudioOnly() ?
Math.round(track.bandwidth / 1000) + ' kbits/s' : track.height + 'p';
button.appendChild(span);

if (!abrEnabled && track == selectedTrack) {
// If abr is disabled, mark the selected track's resolution.
button.ariaSelected = 'true';
button.appendChild(shaka.ui.Utils.checkmarkIcon());
span.classList.add('shaka-chosen-item');
this.currentSelection.textContent = span.textContent;
if (this.player.getLoadMode() != shaka.Player.LoadMode.SRC_EQUALS) {
for (const track of tracks) {
const button = shaka.util.Dom.createButton();
button.classList.add('explicit-resolution');
this.eventManager.listen(button, 'click',
() => this.onTrackSelected_(track));

const span = shaka.util.Dom.createHTMLElement('span');
if (this.player.isAudioOnly()) {
span.textContent = Math.round(track.bandwidth / 1000) + ' kbits/s';
} else {
span.textContent = track.height + 'p';
}
button.appendChild(span);

if (!abrEnabled && track == selectedTrack) {
// If abr is disabled, mark the selected track's resolution.
button.ariaSelected = 'true';
button.appendChild(shaka.ui.Utils.checkmarkIcon());
span.classList.add('shaka-chosen-item');
this.currentSelection.textContent = span.textContent;
}
this.menu.appendChild(button);
}
this.menu.appendChild(button);
}

// Add the Auto button
Expand Down

0 comments on commit f5f164c

Please sign in to comment.