Despite assurances that iOS 11 Safari would support the Web Audio API, it still seems to be incompatible with this JavaScript code:
//called on page load
get_user_media = get_user_media || navigator.webkitGetUserMedia;
get_user_media = get_user_media || navigator.mozGetUserMedia;
get_user_media.call(navigator, { "audio": true }, use_stream, function () { });
function use_stream(stream){
var audio_context = new AudioContext();
var microphone = audio_context.createMediaStreamSource(stream);
window.source = microphone; // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=934512
var script_processor = audio_context.createScriptProcessor(1024, 1, 1);
script_processor.connect(audio_context.destination);
microphone.connect(script_processor);
//do more stuff which involves processing the data from user's microphone...
}
I copied most of this code without fully understanding it. It is meant to capture the user's microphone for further processing (which it accomplishes in other browsers). However, the code breaks at the
var audio_context = new AudioContext();
line, and no subsequent code runs. I lack error messages as I am unable to debug iOS Safari due to not having a Mac (frustrating!). Can anyone shed light on what could be going wrong and how to resolve it?
e: I should note that I researched and found that using the "webkit" keyword before the Web Audio API in Safari may be necessary, but even changing it to
var audio_context = new webkitAudioContext();
does not work.