micIsOn#
variableoav-p5micIsOn
Whether the microphone is running right now.
Use it to show a hint until sound arrives: if (!micIsOn) text("Allow the microphone", 20, 30);. Reading it never starts the microphone (unlike micLevel), so it is safe to check anywhere. The reason behind a false is in OAVp5.mic.state (off, asking, on, denied or unavailable) and, when something failed, OAVp5.mic.error.
- Type
Boolean
True once the browser has said yes and sound is coming in; false while the microphone is off, still asking, blocked or missing.
Examples
function setup() {
createCanvas(400, 300);
}
function draw() {
background(micIsOn ? 20 : 90);
fill(255);
textAlign(CENTER, CENTER);
text(micIsOn ? 'listening' : 'allow the microphone', width / 2, height / 2);
}Related
micLevelHow loud the microphone hears things, from 0 (a quiet room) to 1 (shouting).startMic()Turns the microphone on and returns a promise that says whether it worked.stopMic()Turns the microphone off and sets every microphone value back to 0.