[英]Control gain on iOS with Web Audio API
I know volume control of an audio tag isn't possible on iOS but I want to bypass that by using Web audio API and modify the value of the gain node. 我知道在iOS上无法对音频标签进行音量控制,但是我想通过使用Web音频API并修改gain节点的值来绕过它。 The code is working on desktop but not on iOS, can you see the problem ? 该代码可在台式机上运行,但不能在iOS上运行,您能看到问题吗?
var soundx = document.getElementById("sound");
var audiocontext = window.AudioContext || window.webkitAudioContext;
var context = new audiocontext;
var source1 = context.createMediaElementSource(soundx);
var gain1 = context.createGain();
soundx.get(0).play();
gain1.connect(context.destination);
source1.connect(gain1);
gain2.gain.value=0.5;
gain1.gain.value=0.5;
您没有将source1连接到gain节点,并且gain2是未定义的(因此将抛出,并且gain1.gain.value设置将不会发生。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.