-
Notifications
You must be signed in to change notification settings - Fork 7.5k
feat: logarithmic volume support #9124
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
base: main
Are you sure you want to change the base?
feat: logarithmic volume support #9124
Conversation
|
💖 Thanks for opening this pull request! 💖 Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
2ebb9a9 to
10ac980
Compare
3c3be5d to
90c3f5b
Compare
90c3f5b to
f7e8515
Compare
f7e8515 to
83a499b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9124 +/- ##
==========================================
+ Coverage 84.31% 84.65% +0.34%
==========================================
Files 120 121 +1
Lines 8154 8199 +45
Branches 1964 1971 +7
==========================================
+ Hits 6875 6941 +66
+ Misses 1279 1258 -21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d0a004f to
9a8063f
Compare
test/unit/controls.test.js
Outdated
| player.dispose(); | ||
| }); | ||
|
|
||
| QUnit.test.only('VolumeBar stepBack() sets volume to 0 when slider would go below threshold', function(assert) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| QUnit.test.only('VolumeBar stepBack() sets volume to 0 when slider would go below threshold', function(assert) { | |
| QUnit.test('VolumeBar stepBack() sets volume to 0 when slider would go below threshold', function(assert) { |
Coverage ought to pass without the only left in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @mister-ben. Updated.
a29c8bb to
3a8ff94
Compare
Description
Addresses: #8498
This PR adds support for logarithmic (perceptual) volume control to Video.js, providing a more natural audio experience that better matches human perception of loudness. When enabled via the
logarithmicVolumeoption, the volume slider uses decibel-based scaling where linear slider movements produce logarithmic volume changes, making volume adjustments feel more consistent across the entire range.The Problem:
As discussed in issue #8498, traditional linear volume control doesn't match how humans perceive sound. With linear scaling:
Specific Changes proposed
Logarithmic volume control solves this by using decibel (dB) scaling, the audio engineering standard that matches human hearing perception (source). This implementation provides finer control at lower volumes where precision matters most - the first 50% of the slider covers roughly 0-6% of actual volume. This solution remains fully backward compatible - linear volume remains the default behavior.
Usage:
New
VolumeTransferclass:src/js/utils/volume-transfer.js- Volume transfer functions for converting between slider position and player volumeVolumeTransfer(base class),LinearVolumeTransfer(default, maintains current behavior), andLogarithmicVolumeTransfer(decibel-based scaling)Updates to
VolumeBar:src/js/controls/volume-control/volume-bar.jsinitVolumeTransfer_()to initialize transfer function based onlogarithmicVolumeoptionhandleMouseMove(),getPercent(),stepForward(), andstepBack()to use transfer functionsNew Player Options:
logarithmicVolumeoption (boolean, default: false)Added
logarithmicVolumeRangeoption (number, default: 50)Tests:
test/unit/utils/volume-transfer.test.js- Test suite covering both transfer implementationsTest Page:
https://christriants.github.io/video.js/sandbox/logarithmic-volume.html
Requirements Checklist
npm run docs:apito error