HTML5增长过去100%

问题描述:

这已经发布几年了,但仍然没有得到解决。我决心使一些在音量播放视频,让我们说150%,但HTML5体积法与任何值的误差大于1 https://www.w3schools.com/tags/av_prop_volume.aspHTML5增长过去100%

这里是我的代码:

javascript:(function(){document.getElementsByTagName('video')[0].volume = 1.5;}()); 

0.5有效,但不是1.5。一个答案说,它给这个错误:

Uncaught DOMException: Failed to set the 'volume' property on 'HTMLMediaElement': The volume provided (2) is outside the range [0, 1]. 

无论如何,我可以做一些与此异常要跑它超出了范围[0,1]?

视频音量是0到1之间的百分比,它不能高于100%。

您可能会发生这种情况的唯一方法是将音频从视频播放器路由到Web Audio API并在那里放大。

https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaElementSource

// create an audio context and hook up the video element as the source 
var audioCtx = new AudioContext(); 
var source = audioCtx.createMediaElementSource(myVideoElement); 

// create a gain node 
var gainNode = audioCtx.createGain(); 
gainNode.gain.value = 2; // double the volume 
source.connect(gainNode); 

// connect the gain node to an output destination 
gainNode.connect(audioCtx.destination); 

您可以从视频音频方面并运行它通过增益节点,以提高音量或类似应用混响音效。注意不要太多增加增益节点的增益,或者已经掌握的音频将开始削波。

最后,您需要将增益节点连接到音频目标,以便它可以输出新的音频。