stopRecording()#
functionoav-p5stopRecording()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
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);
}
}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.recordingIsOnWhether a recording is running right now.recordingSaved()An event you define: it is called when a recording has been saved and checked, with aninfoobject about the file.OAVp5.record.stateWhere the recording is:'off','starting','on'or'saving'.