From f5f164cf87be7b5cacb3308c6a390ad643835a31 Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Wed, 28 Jun 2023 11:07:58 +0200 Subject: [PATCH 1/4] fix(UI): Fix resolution selection on src= --- ui/resolution_selection.js | 42 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/ui/resolution_selection.js b/ui/resolution_selection.js index 7563022791..142b90dc01 100644 --- a/ui/resolution_selection.js +++ b/ui/resolution_selection.js @@ -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'); @@ -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 From bb4b54a4b6518477a88b8e900cda9a2a19b6d801 Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Wed, 28 Jun 2023 12:31:13 +0200 Subject: [PATCH 2/4] Revert "fix(UI): Fix resolution selection on src=" This reverts commit f5f164cf87be7b5cacb3308c6a390ad643835a31. --- ui/resolution_selection.js | 42 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/ui/resolution_selection.js b/ui/resolution_selection.js index 142b90dc01..7563022791 100644 --- a/ui/resolution_selection.js +++ b/ui/resolution_selection.js @@ -8,7 +8,6 @@ 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'); @@ -120,30 +119,25 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu { const abrEnabled = this.player.getConfiguration().abr.enabled; // Add new ones - 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); + 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; } + this.menu.appendChild(button); } // Add the Auto button From 2a3e64951063a9288e50b0ad841d3b6e103ee10a Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Wed, 28 Jun 2023 12:32:20 +0200 Subject: [PATCH 3/4] Update implementation --- ui/resolution_selection.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/resolution_selection.js b/ui/resolution_selection.js index 7563022791..e4a6d98772 100644 --- a/ui/resolution_selection.js +++ b/ui/resolution_selection.js @@ -67,7 +67,12 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu { /** @private */ updateResolutionSelection_() { /** @type {!Array.} */ - let tracks = this.player.getVariantTracks(); + let tracks = []; + // When played with src=, the variant tracks available from + // player.getVariantTracks() represent languages, not resolutions. + if (this.player.getLoadMode() != shaka.Player.LoadMode.SRC_EQUALS) { + tracks = this.player.getVariantTracks(); + } // If there is a selected variant track, then we filter out any tracks in // a different language. Then we use those remaining tracks to display the From 9c4a454933e6c5b9c939990a9f04bf9ca0f92e6b Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Wed, 28 Jun 2023 12:33:33 +0200 Subject: [PATCH 4/4] Add missing require --- ui/resolution_selection.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/resolution_selection.js b/ui/resolution_selection.js index e4a6d98772..f89e3528ba 100644 --- a/ui/resolution_selection.js +++ b/ui/resolution_selection.js @@ -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');