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

Can we increase the volume of video more than %100 ? #1256

Open
heissonly opened this issue Oct 29, 2024 · 1 comment
Open

Can we increase the volume of video more than %100 ? #1256

heissonly opened this issue Oct 29, 2024 · 1 comment

Comments

@heissonly
Copy link

heissonly commented Oct 29, 2024

I want to increase the volume of the video to more than 100%. However, I'm not sure if this is possible with HTML5 video or what the correct JavaScript code would be. There is a thread below. Can we map the JavaScript code from the thread to a hotkey in Vimium?"

https://stackoverflow.com/questions/43794356/html5-volume-increase-past-100/43794379#43794379

I tried to implement below, even though it does work on youtube but not in some of the website. What could be the reason for that?

map openUrl url="javascript:if(!window.audioCtx||!window.gainNode){const\u0020a=document.querySelector('video');if(!a)return;window.audioCtx=new(AudioContext||webkitAudioContext)();const\u0020s=window.audioCtx.createMediaElementSource(a),g=window.audioCtx.createGain();s.connect(g);g.connect(window.audioCtx.destination);window.gainNode=g;}window.gainNode.gain.value=1.5;"

map openUrl url="javascript:if(window.gainNode){window.gainNode.gain.value=1.0;}"

@heissonly
Copy link
Author

After some troubleshooting, I found a solution that works! Here’s the JavaScript code to incrementally increase the volume of HTML5 videos using Vimium key mappings. This could be added in a future update:

The code uses JavaScript to incrementally increase the volume of HTML5 videos through Vimium key mappings.

Code Details

  1. Initial Setup on <a-v> Press:

    map <a-v> openUrl url="javascript:if(!window.audioCtx||!window.gainNode){const\u0020a=document.querySelector('video');if(!a)return;window.audioCtx=new(AudioContext||webkitAudioContext)();const\u0020s=window.audioCtx.createMediaElementSource(a),g=window.audioCtx.createGain();s.connect(g);g.connect(window.audioCtx.destination);window.gainNode=g;}window.gainNode.gain.value+=1.0;"
    • Checks if audioCtx and gainNode exist; if not, it creates an AudioContext and a gainNode:
      • Connects the video’s audio to the gain node, and then routes the output to the destination.
    • Each <a-v> press then increments gainNode.gain.value by 1.0, increasing the volume by 100%.
  2. Volume Reset on <a-b> Press:

    map <a-b> openUrl url="javascript:if(window.gainNode){window.gainNode.gain.value=1.0;}"
    • Resets gainNode.gain.value to 1.0, returning the volume to 100%.

This setup allows each <a-v> press to boost volume incrementally, while <a-b> resets it.

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

No branches or pull requests

1 participant