Skip to content
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

Minimum volume after unmuting #4227

Merged
merged 2 commits into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion src/js/control-bar/mute-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion test/unit/controls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
});

}