这已在几年前发布,但仍未解决.我决定制作能够以150%的音量播放视频的内容,但HTML5音量方法出现错误,其值大于1. https://www.w3schools.com/tags/av_prop_volume.asp
这是我的代码:
javascript:(function(){document.getElementsByTagName('video')[0].volume = 1.5;}());
Run Code Online (Sandbox Code Playgroud)
0.5作品但不是1.5.一个答案说,它给出了这个错误:
Uncaught DOMException: Failed to set the 'volume' property on 'HTMLMediaElement': The volume provided (2) is outside the range [0, 1].
Run Code Online (Sandbox Code Playgroud)
无论如何,我可以用这个例外做一些让它超出范围[0,1] ??
Sov*_*iut 22
视频量是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);
Run Code Online (Sandbox Code Playgroud)
您可以从视频中获取该音频上下文并通过增益节点运行它以增强音量或应用混响等音频效果.小心不要过多地增加增益节点上的增益或者已经掌握的音频将开始削波.
最后,您需要将增益节点连接到音频目标,以便它可以输出新音频.
| 归档时间: |
|
| 查看次数: |
2830 次 |
| 最近记录: |