本文介绍了Javascript:控制Google Chrome浏览器的打开标签的音量控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以以编程方式控制我想要的选项卡上的音频电平,而不管Web应用程序是如何设计的(无论是HTML5音频元素还是Flash等)?

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.)?

为了明确起见,我无意研究某些"id""elements"之类的网页,但不喜欢Chrome.ThisAudioOutputLevels ...之类的东西?

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

推荐答案

承认音频来自<audio> HTML元素,您可以尝试从DOM中获取所有音频元素并降低其音量.我在Google环聊会议上遇到了这个问题,在这里我无法降低音频,因为它无法控制任何声音.

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.

我选择了所有<audio>元素并降低了它们的音量.请按照下列步骤操作:

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

  1. 在给定的选项卡上打开控制台. (按F12键.)
  2. 选择所有音频元素.
  3. 降低每个音频音量.
let audios = [...document.getElementsByTagName('audio')];
audios.forEach(audio => audio.volume = 0.5) // lower volume 50%.

音量范围= {0..1},其中0 =无音量.

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

这篇关于Javascript:控制Google Chrome浏览器的打开标签的音量控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 02:29