user963720
user963720

Reputation:

Javascript: control Google Chrome's open tab audio volume control

Is there a way to programmatic-ally control audio level on tabs i want to regardless of how web app was designed (be it HTML5 Audio element or Flash, etc.)?

Just to make it clear i don't intend to research web page for some "id" "elements" or whatsoever, but something like Chrome.ThisAudioOutputLevels...?

Upvotes: 7

Views: 6212

Answers (2)

Diogo Mafra
Diogo Mafra

Reputation: 479

Admitting that the audio comes from a <audio> HTML element, you can try to get all audio elements from the DOM and lower their volumes. I was suffering from this with google hangouts meetings where I couldn't lower the audio because it had no control whatsoever.

"The solution"

I selected all <audio> elements and lowered their volumes. Follow these steps:

  1. Open your console on the given tab. (Press F12).
  2. Select all audio elements.
  3. Lower each audio volume.
let audios = [...document.getElementsByTagName('audio')];
audios.forEach(audio => audio.volume = 0.5) // lower volume 50%.

Volume range = {0..1} where 0 = no volume.

Upvotes: 8

nickRise
nickRise

Reputation: 96

This is more of a comment than an answer, but I can't comment, so:

Browsers generally try not to change how the content is meant to be displayed, including sound. For this reason, I would be surprised if there were such a feature.

If you're trying to simply mute tabs, you could take a look at chrome://flags/#enable-tab-audio-muting

Alternatively you could use tampermonkey or a similar extension and run a search for all audio/video tags and change the volume, but you said you didn't want to search for specific elements. To my knowledge (and Google's) as of right now there is no volume control for an entire page.

Upvotes: 2

Related Questions