OAVp5.mic.state#
variableoav-p5OAVp5.mic.state
Where the microphone is: 'off', 'asking', 'on', 'denied' or 'unavailable'.
'off': not started, or stopped. 'asking': the browser is waiting for the user's answer. 'on': sound is coming in, and micIsOn is true. 'denied': the permission was refused (by the user, by the computer's settings, or by an iframe without allow="microphone"). 'unavailable': there is no microphone, none the browser can open, or the page is not on https or localhost. When it is not 'on', OAVp5.mic.error has the browser's reason and a card beside the 🎹 says what to press.
- Type
String- Range
'off' | 'asking' | 'on' | 'denied' | 'unavailable'
Changes when you start or stop the microphone and when the browser answers. 'off' until something starts it. Reading it never starts it.
Examples
function setup() {
createCanvas(400, 300);
startMic();
}
function draw() {
background(OAVp5.mic.state === 'on' ? 20 : color(90, 30, 30));
fill(255);
text('microphone: ' + OAVp5.mic.state, 20, 30);
if (OAVp5.mic.state === 'denied') text('click the lock left of the address and allow it', 20, 60);
}Related
micIsOnWhether the microphone is running right now.OAVp5.mic.errorWhy the microphone did not start, as the browser's error name such as'NotAllowedError';nullwhile there is no error.startMic()Turns the microphone on and returns a promise that says whether it worked.micWho may turn the microphone on:auto(the first read ofmicLeveland friends),click(only 🎤 orstartMic()) oroff(nobody).OAVp5.check()Runs the 🩺 check-up: the version, page, browser, microphone, MIDI, sound, drums, recording, wiring and hints, as a card to screenshot and as an object.