recordingIsOn#
variableoav-p5recordingIsOn
Whether a recording is running right now.
Use it to keep things out of the video: if (!recordingIsOn) text('press r to record', 20, 30);, because everything on the canvas is recorded. Use it for a key that toggles: recordingIsOn ? stopRecording() : startRecording(). It changes when a take starts and when it ends, and reading it never starts anything. For the other stages (starting, saving) read OAVp5.record.state.
- Type
Boolean
True while a take runs. It is false at the start, while the recorder is still loading, from the moment stopRecording() is called (the file is then being made) and after the take.
Notes
- A sketch that declares its own variable called
recordingIsOnkeeps it: oav-p5 leaves the name alone and a card says to readOAVp5.record.state === 'on'instead.
Examples
function setup() {
createCanvas(400, 300);
textSize(16);
}
function keyPressed() {
if (key === 'r') recordingIsOn ? stopRecording() : startRecording();
}
function draw() {
background(20);
fill(255, 120, 90);
circle(200 + sin(frameCount * 0.05) * 120, 150, 50);
if (!recordingIsOn) { // the guide never reaches the video
fill(255);
text('r: start / stop recording', 20, 30);
}
}Related
startRecording()Records the canvas and the sound your sketch makes into one video file, and returns a promise that says whether the recording began.stopRecording()Stops the recording; the video is finished, downloaded, and handed torecordingSaved(info)and to the returned promise.OAVp5.record.stateWhere the recording is:'off','starting','on'or'saving'.soundIsOnWhether notes are being heard right now: true oncestartSound()has finished, false before and after.drumsAreOnWhether the drum machine is playing right now.