open-audiovisual
Search GitHub

oav-p5 reference · Recording

recordingIsOn#

variableoav-p5
recordingIsOn

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 recordingIsOn keeps it: oav-p5 leaves the name alone and a card says to read OAVp5.record.state === 'on' instead.

Examples

jsOpenProcessing ↗
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);
  }
}
The guide text is on the canvas until you press r, and gone while recording, so the video has only the circle.

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 to recordingSaved(info) and to the returned promise.
  • OAVp5.record.state Where the recording is: 'off', 'starting', 'on' or 'saving'.
  • soundIsOn Whether notes are being heard right now: true once startSound() has finished, false before and after.
  • drumsAreOn Whether the drum machine is playing right now.

p5/oav-p5.js, line 317

↑ Back to top · All names