OAVp5.mic.error#
variableoav-p5OAVp5.mic.error
Why the microphone did not start, as the browser's error name such as 'NotAllowedError'; null while there is no error.
For a sketch that wants to say more than a card does: if (OAVp5.mic.error === 'NotAllowedError') …. The card beside the 🎹 already tells the user what to press for each of these, in their language; this is the same fact for your code.
- Type
String | null
null at the start and again once the microphone is on. After a failure: the browser's error name ('NotAllowedError' or 'SecurityError' for a refusal, 'NotFoundError' when there is no microphone, 'NotReadableError' when another program holds it) or 'no getUserMedia' on a page that cannot ask.
Examples
function setup() {
createCanvas(400, 300);
startMic();
}
function draw() {
background(20);
fill(255);
text('state: ' + OAVp5.mic.state, 20, 30);
text('error: ' + OAVp5.mic.error, 20, 60); // null while all is well
}Related
OAVp5.mic.stateWhere the microphone is:'off','asking','on','denied'or'unavailable'.startMic()Turns the microphone on and returns a promise that says whether it worked.micIsOnWhether the microphone is running right now.