VideoJS HTML5 Video JS如何将音量提高到最大值以上? [英] VideoJS HTML5 Video JS How to boost volume above maximum?

查看:105
本文介绍了VideoJS HTML5 Video JS如何将音量提高到最大值以上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能对此没有解决方案,但我想我还是会打听.有时视频确实很安静,如果我相应地调高计算机的音量,结果其他声音会变得太大.能够将音量提高到最大值会很好.

Its possible there's no solution to this but I thought I'd inquire anyway. Sometimes a video is really quiet and if I turn the volume of my computer up accordingly then other sounds I have become way too loud as a result. It would be nice to be able to boost the volume above maximum.

我在Google上进行了一次搜索,从字面上什么都没有发现,实际上甚至没有与videojs相关的结果.Mac上的某些视频几乎处于最大音量,无法很好地听到视频的讲话,因此从所有较低的音量开始并进行相应调整是不可行的.

I did a search on google which literally turned up nothing at all, not even results related to videojs at all in fact. Some videos my Mac is almost at max volume to hear the video's speech well so it would not be feasible to start with everything at a lower volume and adjust accordingly.

我尝试过:

   var video = document.getElementById("Video1");
   video.volume = 1.0;

并将其设置为1.0以上,但视频根本无法打开:

And setting it to anything above 1.0 but the video then fails to open at all:

   var video = document.getElementById("Video1");
   video.volume = 1.4;  /// 2.0 etc

推荐答案

基于:您可以使用Web Audio API调整增益:

You can adjust the gain by using the Web Audio API:

function amplifyMedia(mediaElem, multiplier) {
  var context = new(window.AudioContext || window.webkitAudioContext),
    result = {
      context: context,
      source: context.createMediaElementSource(mediaElem),
      gain: context.createGain(),
      media: mediaElem,
      amplify: function(multiplier) {
        result.gain.gain.value = multiplier;
      },
      getAmpLevel: function() {
        return result.gain.gain.value;
      }
    };
  result.source.connect(result.gain);
  result.gain.connect(context.destination);
  result.amplify(multiplier);
  return result;
}

amplifyMedia(document.getElementById('myVideo'), 1.4);

传递给该函数的乘数与视频音量处于同一水平,即100%的音量为1,但是在这种情况下,您可以传递更大的数字.

The multiplier you pass to the function is at same level as the video volume, being 1 the 100% volume, but in this case you can pass a higher number.

无法发布任何有效的演示或JSFiddle,因为Web Audio API要求来源相同(或与CORS兼容).您可以在控制台中看到错误: https://jsfiddle.net/yuriy636/41vrx1z7/1/

Can't post any working demo or JSFiddle because Web Audio API requires a source from the same origin (or CORS compatible). You can see the error in the console: https://jsfiddle.net/yuriy636/41vrx1z7/1/

由于CORS访问限制,MediaElementAudioSource输出零

MediaElementAudioSource outputs zeroes due to CORS access restrictions

但是我已经在本地进行了测试,并且可以按预期工作.

But I have tested locally and it works as intended.

这篇关于VideoJS HTML5 Video JS如何将音量提高到最大值以上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆