Home:ALL Converter>Control gain on iOS with Web Audio API

Control gain on iOS with Web Audio API

Ask Time:2016-10-06T00:14:46         Author:Gautier Bourdonnay

Json Formatter

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. The code is working on desktop but not on iOS, can you see the problem ?

    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;

Author:Gautier Bourdonnay,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/39879057/control-gain-on-ios-with-web-audio-api
yy