open-audiovisual
Search GitHub

oav-p5 reference · Recording

OAVp5.record.seconds#

variableoav-p5
OAVp5.record.seconds

How long the running take has been going, in seconds, and the length of the last take after it.

Use it as a clock that starts with the take: const t = recordingIsOn ? OAVp5.record.seconds : 0; makes an animation that always begins at 0 in the video. It is the time since the recording began, not the time of the sketch, so it does not count the moment before startRecording().

Type
Number
Range
0 …

0 at the start, then refreshed four times a second while recording. When the take is saved it is that take's length, and the next take sets it back to 0.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
}

function keyPressed() {
  if (key === 'r') startRecording(4);
}

function draw() {
  background(20);
  const t = recordingIsOn ? OAVp5.record.seconds : 0;   // 0 at the first frame of the video
  fill(255, 160, 80);
  circle(40 + t * 80, 150, 40);                         // slides right, 80 px a second
  if (!recordingIsOn) {
    fill(255);
    text('press r: the video starts with the circle at the left', 20, 30);
  }
}
Press r: the circle jumps to the left edge and slides right for four seconds, so the video always begins the same way.

Related

  • recordingIsOn Whether a recording is running right now.
  • OAVp5.record.state Where the recording is: 'off', 'starting', 'on' or 'saving'.
  • startRecording() Records the canvas and the sound your sketch makes into one video file, and returns a promise that says whether the recording began.
  • OAVp5.record.last The info of the last recording that was saved (the same object recordingSaved got), or null before the first one.

p5/oav-p5.js, line 1916

↑ Back to top · All names