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

[Plugin] Precise volume control #236

Merged
merged 22 commits into from
May 2, 2021
Merged

[Plugin] Precise volume control #236

merged 22 commits into from
May 2, 2021

Conversation

Araxeus
Copy link
Collaborator

@Araxeus Araxeus commented Apr 16, 2021

precise-volume plugin

The original volume slider and shortcuts lets you control volume only in steps of 5% or 10%,
this has always bothered me, there isn't enough control - especially around the lower percentages

So I made this small plugin to fix that (name could be changed):

Features

  • You can now have precise control over volume percentage by using mouse-wheel in play bar area (bottom bar)
    each step add/subtract [1%] (default can be changed)

  • Optional setting to change volume with local hotkey - arrowkeys up/down (Like in native youtube)

  • Advanced option in config to setup global hotkeys

  • Advanced option to change volume steps (int 1-100 representing percentage change)
    Will use prompt type: "Counter" to allow controlling this setting once the custom prompt from Menu tweaks #224 gets implemented

  • Plugin also makes the Volume slider + icon tooltip's always show the exact current volume percentage

  • Precise volume is saved and restored between sessions


Misc

To override the default mousewheel + arrowkey behavior of the volume bar, I had to do a trick before DOMContent loaded
(The only way to remove an eventListener created with an anonymous function is to catch it before its created)

Initially I just added the code to the main preload.js but later thought it would probably be better to enable all plugins to do some preload
so, I added an option for Every Plugin to add a preload.js to be executed from Renderer before DOMContent loaded

Note on the original volume slider

  • Dragging it with the cursor still works the same way.
  • When changing the volume using this plugin - it gets visually updated only around every 5% volume
    For example, there is no visual difference between 5% and 7%
    (that's pretty much the main reason I added the tooltip with volume percentage)

I'm not too sure how to visually modify the slider itself without native youtube functionality breaking, if it's even possible

Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good and seems to work fine, thanks for the contribution! Just a comment to make the code defensive and then it should be good to merge 👍

Co-authored-by: th-ch <[email protected]>
@th-ch
Copy link
Owner

th-ch commented May 2, 2021

Looks ok, thanks for the contribution, merging! ✅

@th-ch th-ch merged commit 2567702 into th-ch:master May 2, 2021
@Araxeus Araxeus deleted the precise-volume branch May 6, 2021 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants