So far as I can inform, essentially the most fundamental webAudio performance now not works on iOS cellular Safari, or else some bizarre new requirement is now in place. Code that runs fantastic in different browsers (together with desktop Safari) produces no errors, however no sound in cellular Safari.
I’ve tried many ultra-simple examples of a person gesture to play a fundamental sound.
I simply found that these examples WILL produce audio on iOS Safari, however provided that bluetooth will not be getting used and has not been used. As soon as bluetooth audio is used, so far as I can inform the one technique to get webAudio to work once more is to restart the Safari browser (with bluetooth off).
Here is one stay instance on the internet:
https://codepen.io/LegDip/pen/KKQOMRr
Here is the code:
let context;
let mediaStream;
perform createAudioContext() {
if (context == undefined) {
context = new AudioContext();
}
return context;
}
perform playTone() {
const audioContext = createAudioContext();
// play a tone
const oscillator = audioContext.createOscillator();
oscillator.frequency.worth = 440;
// do not play at max quantity
const achieve = audioContext.createGain();
achieve.achieve.worth = 0.04;
oscillator.join(achieve);
achieve.join(audioContext.vacation spot);
oscillator.begin();
// cease after 10 seconds
oscillator.cease(audioContext.currentTime + 10);
}
Here is one other fully unbiased instance, which as soon as once more works fantastic in different browser contexts. The perform playTone is named instantly by a person button faucet in a vue app:
const audioContext = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: 44100 });
playTone() {
audioContext.resume()
const oscillator = audioContext.createOscillator();
oscillator.frequency.worth = 440; // A4 notice (440 Hz)
oscillator.join(audioContext.vacation spot);
oscillator.begin();
oscillator.cease(audioContext.currentTime + 1); // Cease after 1 second
}
I’ve tried various different ultra-simple examples and every part below the solar that both me or chatGPT can consider to repair it.
Is there a repair?
Is it doable to wrap a webapp in chromium to resolve this, or on iOS will which have the identical drawback?
Does the world simply have to all concurrently toss their iPhones within the sea?
Thanks