mirror of
https://github.com/videojs/video.js.git
synced 2025-02-02 11:34:50 +02:00
fix: keep minimum volume after unmuting above 0.1 (#4227)
If, when unmuting, the last volume is below 0.1, force it to be 0.1. Fixes #4054.
This commit is contained in:
parent
7d12c9ea85
commit
16c1e0adc0
@ -57,7 +57,9 @@ class MuteToggle extends Button {
|
||||
const lastVolume = this.player_.lastVolume_();
|
||||
|
||||
if (vol === 0) {
|
||||
this.player_.volume(lastVolume);
|
||||
const volumeToSet = lastVolume < 0.1 ? 0.1 : lastVolume;
|
||||
|
||||
this.player_.volume(volumeToSet);
|
||||
this.player_.muted(false);
|
||||
} else {
|
||||
this.player_.muted(this.player_.muted() ? false : true);
|
||||
|
@ -148,6 +148,20 @@ if (Html5.isSupported()) {
|
||||
assert.equal(player.muted(), false, 'muted is set to false');
|
||||
});
|
||||
|
||||
QUnit.test('Clicking MuteToggle when volume is 0, lastVolume is less than 0.1, and muted is true sets volume to 0.1 and muted to false', function(assert) {
|
||||
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
|
||||
const muteToggle = new MuteToggle(player);
|
||||
|
||||
player.volume(0);
|
||||
player.muted(true);
|
||||
player.lastVolume_(0.05);
|
||||
|
||||
muteToggle.handleClick();
|
||||
|
||||
assert.equal(player.volume(), 0.1, 'since lastVolume is less than 0.1, volume is set to 0.1');
|
||||
assert.equal(player.muted(), false, 'muted is set to false');
|
||||
});
|
||||
|
||||
QUnit.test('ARIA value of VolumeBar should start at 100', function(assert) {
|
||||
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
|
||||
const volumeBar = new VolumeBar(player);
|
||||
@ -179,5 +193,4 @@ if (Html5.isSupported()) {
|
||||
assert.equal(player.muted(), true, 'Muted is true');
|
||||
assert.equal(volumeBar.el_.getAttribute('aria-valuenow'), 0, 'ARIA value of VolumeBar is 0');
|
||||
});
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user