open-audiovisual
Search GitHub

oav-p5 reference · Recording

OAVp5.record.state#

variableoav-p5
OAVp5.record.state

Where the recording is: 'off', 'starting', 'on' or 'saving'.

recordingIsOn is state === 'on'. Read the state when the other stages matter: a button can show "starting…" and "saving…" and refuse a new take while one is being saved.

Type
String
Range
off | starting | on | saving

Starts as 'off'. A take goes 'starting' (the recorder is loading, the first time), 'on' (recording), 'saving' (the file is being made) and back to 'off'.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  textAlign(CENTER, CENTER);
  textSize(28);
}

function keyPressed() {
  if (key === 'r' && OAVp5.record.state === 'off') startRecording(3);
}

function draw() {
  background(20);
  circle(200 + sin(frameCount * 0.05) * 120, 220, 40);
  fill(255);
  text(OAVp5.record.state === 'off' ? 'press r' : OAVp5.record.state, width / 2, 70);
}
Press r: the word goes through starting, on and saving and comes back to the prompt; the key does nothing in between.

Related

  • recordingIsOn Whether a recording is running right now.
  • 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 The object behind the recording names: the state, the time, the last file, the formats this browser can write and the screenshot function.

p5/oav-p5.js, line 1915

↑ Back to top · All names