From 2244554a07eeaecd15c9f619c2ddd9b355bf45be Mon Sep 17 00:00:00 2001 From: Keegan Dahm <88423495+keegandahm@users.noreply.github.com> Date: Sat, 7 Aug 2021 07:26:28 -0700 Subject: [PATCH 1/2] Made volume slider exponential rather than linear --- CONTRIBUTORS.md | 1 + src/plugins/htmlAudioPlayer/plugin.js | 4 ++-- src/plugins/htmlVideoPlayer/plugin.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4667efb311..9898aa9abe 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -46,6 +46,7 @@ - [danieladov](https://github.com/danieladov) - [Stephane Senart](https://github.com/ssenart) - [Ömer Erdinç Yağmurlu](https://github.com/omeryagmurlu) + - [Keegan Dahm](https://github.com/keegandahm) # Emby Contributors diff --git a/src/plugins/htmlAudioPlayer/plugin.js b/src/plugins/htmlAudioPlayer/plugin.js index 446829a03e..99cef50396 100644 --- a/src/plugins/htmlAudioPlayer/plugin.js +++ b/src/plugins/htmlAudioPlayer/plugin.js @@ -457,14 +457,14 @@ class HtmlAudioPlayer { setVolume(val) { const mediaElement = this._mediaElement; if (mediaElement) { - mediaElement.volume = val / 100; + mediaElement.volume = Math.pow(val / 100, 2); } } getVolume() { const mediaElement = this._mediaElement; if (mediaElement) { - return Math.min(Math.round(mediaElement.volume * 100), 100); + return Math.min(Math.round(Math.pow(mediaElement.volume, 0.5) * 100), 100); } } diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 7b3afb635a..08137e02fa 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1708,14 +1708,14 @@ function tryRemoveElement(elem) { setVolume(val) { const mediaElement = this.#mediaElement; if (mediaElement) { - mediaElement.volume = val / 100; + mediaElement.volume = Math.pow(val / 100, 2); } } getVolume() { const mediaElement = this.#mediaElement; if (mediaElement) { - return Math.min(Math.round(mediaElement.volume * 100), 100); + return Math.min(Math.round(Math.pow(mediaElement.volume, 0.5) * 100), 100); } } From 4f7131f59a767af5b37770379ffb1f3396454d30 Mon Sep 17 00:00:00 2001 From: Keegan Dahm <88423495+keegandahm@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:16:52 -0700 Subject: [PATCH 2/2] Changed volume curve from x^2 to x^3 --- src/plugins/htmlAudioPlayer/plugin.js | 4 ++-- src/plugins/htmlVideoPlayer/plugin.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/htmlAudioPlayer/plugin.js b/src/plugins/htmlAudioPlayer/plugin.js index 99cef50396..1e7d47f099 100644 --- a/src/plugins/htmlAudioPlayer/plugin.js +++ b/src/plugins/htmlAudioPlayer/plugin.js @@ -457,14 +457,14 @@ class HtmlAudioPlayer { setVolume(val) { const mediaElement = this._mediaElement; if (mediaElement) { - mediaElement.volume = Math.pow(val / 100, 2); + mediaElement.volume = Math.pow(val / 100, 3); } } getVolume() { const mediaElement = this._mediaElement; if (mediaElement) { - return Math.min(Math.round(Math.pow(mediaElement.volume, 0.5) * 100), 100); + return Math.min(Math.round(Math.pow(mediaElement.volume, 1 / 3) * 100), 100); } } diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 08137e02fa..275b7d0580 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1708,14 +1708,14 @@ function tryRemoveElement(elem) { setVolume(val) { const mediaElement = this.#mediaElement; if (mediaElement) { - mediaElement.volume = Math.pow(val / 100, 2); + mediaElement.volume = Math.pow(val / 100, 3); } } getVolume() { const mediaElement = this.#mediaElement; if (mediaElement) { - return Math.min(Math.round(Math.pow(mediaElement.volume, 0.5) * 100), 100); + return Math.min(Math.round(Math.pow(mediaElement.volume, 1 / 3) * 100), 100); } }