open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

OAVp5.mic.error#

variableoav-p5
OAVp5.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

jsOpenProcessing ↗
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
}
Prints the state and the error. Refuse the microphone to see "NotAllowedError". Asks for the microphone

Related

  • OAVp5.mic.state Where the microphone is: 'off', 'asking', 'on', 'denied' or 'unavailable'.
  • startMic() Turns the microphone on and returns a promise that says whether it worked.
  • micIsOn Whether the microphone is running right now.

p5/oav-p5.js, line 899

↑ Back to top · All names