La reciente actualización de IOS/Safari parece romper la API de audio web...
Mire aquí el código simple que funcionó antes en IOS y Safari, pero desde la actualización ya no funciona ... por cierto, funciona en Firefox, Edge, Chrome.
https://www.mylooper.com/debug.html
var url = 'https://www.mylooper.com/static/btf_10_loop1.aac'; var context = new AudioContext(); var source = context.createBufferSource(); //connect it to the destination so you can hear it. source.connect(context.destination); /* --- load buffer --- */ var request = new XMLHttpRequest(); //open the request request.open('GET', url, true); //webaudio paramaters request.responseType = 'arraybuffer'; request.onload = function() { context.decodeAudioData(request.response, function(response) { /* --- play the sound AFTER the buffer loaded --- */ //set the buffer to the response we just received. source.buffer = response; source.start(0); source.loop = true; }, function () { console.error('The request failed.'); } ); } //Now that the request has been defined, actually make the request. (send it) request.send(); </script>Gran parte de la biblioteca se ve afectada como Howler js, tuna js... pero no sé si este "error"/"característica" puede solucionarse algún día...
Por cierto, por ahora, ¿cómo hacer un bucle de audio perfecto con JS ahora en Safari/IOS?
Muchas gracias, esto me está volviendo loco...
¿Qué quieres decir con "roto"?
Si significa que el audio no comienza a reproducirse con esta advertencia, debe llamar a source.start(0) después del gesto del usuario.
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. Por ejemplo, llame a request.send() en la función onclick de algún botón.
O envuelva todo su código en la función onclick de algún botón.
const button = document.getElementbyId("foo"); button.oncklick = () => { var url = 'https://www.mylooper.com/static/btf_10_loop1.aac'; var context = new AudioContext(); var source = context.createBufferSource(); //connect it to the destination so you can hear it. source.connect(context.destination); /* --- load buffer --- */ var request = new XMLHttpRequest(); //open the request request.open('GET', url, true); //webaudio paramaters request.responseType = 'arraybuffer'; request.onload = function() { context.decodeAudioData(request.response, function(response) { /* --- play the sound AFTER the buffer loaded --- */ //set the buffer to the response we just received. source.buffer = response; source.start(0); source.loop = true; }, function () { console.error('The request failed.'); } ); } //Now that the request has been defined, actually make the request. (send it) request.send(); } Esta es la característica descrita aquí. https://developer.chrome.com/blog/autoplay/#webaudio
Así que no se arreglará.