Skip to content

feat(UI): Add alwaysShowVolumeBar config #8807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ shaka.extern.UIQualityMarks;
* showAudioCodec: boolean,
* showVideoCodec: boolean,
* castSenderUrl: string,
* enableKeyboardPlaybackControlsInWindow: boolean
* enableKeyboardPlaybackControlsInWindow: boolean,
* alwaysShowVolumeBar: boolean
* }}
*
* @property {!Array<string>} controlPanelElements
Expand Down Expand Up @@ -374,6 +375,11 @@ shaka.extern.UIQualityMarks;
* <code>enableKeyboardPlaybackControls</code> is true.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} alwaysShowVolumeBar
* Always show the volume bar, even when the volume and mute bars are next to
* each other.
* <br>
* Defaults to <code>false</code>.
* @exportDoc
*/
shaka.extern.UIConfiguration;
Expand Down
6 changes: 3 additions & 3 deletions ui/less/range_elements.less
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@
}
}

.shaka-mute-button:hover + .shaka-volume-bar-container {
.shaka-mute-button:hover + .shaka-volume-bar-container-allow-hiding {
width: 50px;
opacity: 1;
}
}

.shaka-mute-button + .shaka-volume-bar-container {
.shaka-mute-button + .shaka-volume-bar-container-allow-hiding {
width: 0;
opacity: 0;
}

@media (min-width: 475px) {
.shaka-mute-button:hover + .shaka-volume-bar-container {
.shaka-mute-button:hover + .shaka-volume-bar-container-allow-hiding {
width: 100px;
opacity: 1;
}
Expand Down
1 change: 1 addition & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ shaka.ui.Overlay = class {
showVideoCodec: true,
castSenderUrl: 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js',
enableKeyboardPlaybackControlsInWindow: false,
alwaysShowVolumeBar: false,
};

// On mobile, by default, hide the volume slide and the small play/pause
Expand Down
4 changes: 4 additions & 0 deletions ui/volume_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ shaka.ui.VolumeBar = class extends shaka.ui.RangeElement {
/** @private {!shaka.extern.UIConfiguration} */
this.config_ = this.controls.getConfig();

if (!this.config_.alwaysShowVolumeBar) {
this.container.classList.add('shaka-volume-bar-container-allow-hiding');
}

// We use a range of 100 to avoid problems with Firefox.
// See https://github.com/shaka-project/shaka-player/issues/3987
this.setRange(0, 100);
Expand Down
Loading