Skip to content

Commit 9992d67

Browse files
authored
feat(UI): Show current playback rate and quality without hover (#8437)
Close #7444
1 parent f760dbd commit 9992d67

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

ui/less/overflow_menu.less

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@
160160
line-height: 6px;
161161
}
162162

163-
.shaka-overflow-quality-mark {
163+
.shaka-overflow-quality-mark,
164+
.shaka-overflow-playback-rate-mark {
164165
background: @quality-mark-hightlight-color;
165166
color: @quality-mark-color;
166167
border-radius: 2px;
167168
font-family: @general-font-family;
168169
font-size: 10px;
169170
font-weight: bold;
171+
line-height: 10px;
170172
text-shadow: none;
171173
padding: 1px;
172174
position: absolute;

ui/playback_rate_selection.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ shaka.ui.PlaybackRateSelection = class extends shaka.ui.SettingsMenu {
3434
this.menu.classList.add('shaka-playback-rates');
3535
this.button.classList.add('shaka-tooltip-status');
3636

37+
if (!Array.from(parent.classList).includes('shaka-overflow-menu')) {
38+
this.playbackRateMark = shaka.util.Dom.createHTMLElement('span');
39+
this.playbackRateMark.classList.add('shaka-overflow-playback-rate-mark');
40+
this.button.appendChild(this.playbackRateMark);
41+
}
42+
3743
this.eventManager.listen(
3844
this.localization, shaka.ui.Localization.LOCALE_UPDATED, () => {
3945
this.updateLocalizedStrings_();
@@ -105,6 +111,9 @@ shaka.ui.PlaybackRateSelection = class extends shaka.ui.SettingsMenu {
105111
// in the format of '1x', '1.5x', etc.
106112
this.currentSelection.textContent = rate + 'x';
107113
this.button.setAttribute('shaka-status', rate + 'x');
114+
if (this.playbackRateMark) {
115+
this.playbackRateMark.textContent = rate + 'x';
116+
}
108117
}
109118

110119
/** @private */

ui/resolution_selection.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
4949
this.qualityMark.classList.add('shaka-current-quality-mark');
5050
this.qualityMark.style.display = 'none';
5151

52-
if (this.parent.parentElement) {
52+
if (!Array.from(parent.classList).includes('shaka-overflow-menu')) {
53+
this.overflowQualityMark = shaka.util.Dom.createHTMLElement('span');
54+
this.overflowQualityMark.classList.add(
55+
'shaka-overflow-playback-rate-mark');
56+
this.button.appendChild(this.overflowQualityMark);
57+
} else if (this.parent.parentElement) {
5358
const parentElement =
5459
shaka.util.Dom.asHTMLElement(this.parent.parentElement);
5560
this.overflowQualityMark = shaka.util.Dom.getElementByClassNameIfItExists(
56-
'shaka-overflow-quality-mark', parentElement,
57-
);
61+
'shaka-overflow-quality-mark', parentElement);
5862
}
5963

6064
const spanWrapper = shaka.util.Dom.createHTMLElement('span');

0 commit comments

Comments
 (0)