Open heissonly opened 1 week ago
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.
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;"
audioCtx
and gainNode
exist; if not, it creates an AudioContext
and a gainNode
:
<a-v>
press then increments gainNode.gain.value
by 1.0
, increasing the volume by 100%.Volume Reset on <a-b>
Press:
map <a-b> openUrl url="javascript:if(window.gainNode){window.gainNode.gain.value=1.0;}"
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.
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;}"