open-audiovisual
Search GitHub

oav-p5 reference · Recording

stopRecording()#

functionoav-p5
stopRecording()

Also: OAVp5.record.stop

Stops the recording; the video is finished, downloaded, and handed to recordingSaved(info) and to the returned promise.

It ends a take that has no seconds, or ends one early. recordingIsOn turns false at once, while the file is made (OAVp5.record.state is 'saving' until then), so the promise or recordingSaved() is how you know the file is ready. Both come after a fraction of a second, a little more for a long take.

Returns

Promise<Object | null> Resolves, once the file is saved and checked, to the same info that recordingSaved(info) gets. Resolves to null at once when nothing is recording, or when the recording was still starting (nothing was recorded then).

Examples

jsOpenProcessing ↗
let message = 'press r to record, r again to stop';

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

function keyPressed() {
  if (key !== 'r') return;
  if (recordingIsOn) {
    stopRecording().then((info) => {
      if (info) message = 'saved ' + info.name;   // the file is ready
    });
  } else {
    startRecording();
  }
}

function draw() {
  background(20);
  circle(200 + sin(frameCount * 0.05) * 120, 150, 50);
  if (!recordingIsOn) {
    fill(255);
    text(message, 20, 30);
  }
}
Press r to start and r to stop: once the file is ready the text names it.

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.
  • recordingIsOn Whether a recording is running right now.
  • recordingSaved() An event you define: it is called when a recording has been saved and checked, with an info object about the file.
  • OAVp5.record.state Where the recording is: 'off', 'starting', 'on' or 'saving'.

p5/oav-p5.js, line 2336

↑ Back to top · All names