Skip to content
Advertisement

Increase (youtube flash) video’s sound volume by means of JavaScript

Background story: many users (including me) browse the web from notebooks that are not constructed for sound performance. That means (besides other things) that the sound volume for most videos is too low, especially if the video itself is recorded at low volume.

Therefore

I was wondering if there is any way of increasing the volume of such a video (especially Youtube, but could be extended to other types), because I’m interested in doing it and even publishing it as Firefox/Chrome/other browser plug-in.

Or, alternatively, if you know such a plug-in do not hesitate to post the link here.

Advertisement

Answer

If you want to control system volume then JavaScript has no direct access to it, you would need to write NPAPI (C++ dll) plugin.

If you want to just adjust video player’s own volume (you won’t be able to increase it beyond 100%) then JavaScript can do it, perhaps.

If video player is HTML5 <video> tag then controlling volume is easy. For YouTube it would be:

document.getElementsByClassName("video-stream")[0].volume = 0.5; //50%

If it is a custom made flash player then you need to rely on its JavaScript interface, if any. Youtube player happens to support controlling volume with JavaScript:

document.getElementById("movie_player").setVolume(50);

In order for this to work you would need to break out of extension sandbox first by injecting <script> tag on the page with this code.

There is no universal solution, you would need to deal with each site individually.

Advertisement