I read an article introducing HTML5 Web Audio API
.
It's very interesting with my desktop Chrome.
However, is this not working for mobile?
I read an article introducing HTML5 Web Audio API
.
It's very interesting with my desktop Chrome.
However, is this not working for mobile?
The article seems to be about three years old. And back then the autoplay policy of browsers wasn't really affecting the usage of the Web Audio API. That has changed. Now it is required to have a user gesture (typically a click event) to start an AudioContext.
The first example of the referenced article would than look like this:
const $playButton = document.getElementById('play-button');
$playButton.addEventListener('click', () => {
const context = new AudioContext();
const oscillator = context.createOscillator();
oscillator.type = 'sine';
oscillator.connect(context.destination);
oscillator.start();
};
This does assume that you have a button with the id play-button
somewhere in your HTML.
<button id="play-button">play</button>