OAVp5.record.on()#
functionoav-p5OAVp5.record.on(name, fn)
Listens to the recording from anywhere: OAVp5.record.on('saved', fn) or on('start', fn), and it returns a function that stops listening.
recordingSaved() is a single function that you define. on() is for the cases where that does not fit: several listeners, a library, a listener you want to remove again. It is the same idea as OAVp5.drums.on() and midi.on(). An error thrown inside fn is printed and the other listeners still run.
Parameters
| Name | Type | Description |
|---|---|---|
name | String | 'start' (a take began) or 'saved' (a file is saved, like recordingSaved()). Any other name throws an error that lists the two. |
fn | Function | For 'start' it gets { width, height, fps, type, seconds } (seconds is 0 when no length was asked for). For 'saved' it gets the same info as recordingSaved(). |
Returns
Function A function: call it to stop listening.
Examples
let status = 'press r to record 2 seconds';
function setup() {
createCanvas(400, 300);
OAVp5.record.on('start', (i) => { status = 'recording ' + i.width + 'x' + i.height + ' at ' + i.fps + ' fps'; });
OAVp5.record.on('saved', (i) => { status = 'saved ' + i.name; });
}
function keyPressed() {
if (key === 'r') startRecording(2);
}
function draw() {
background(20);
circle(200 + sin(frameCount * 0.05) * 120, 150, 50);
if (!recordingIsOn) {
fill(255);
text(status, 20, 30);
}
}Related
recordingSaved()An event you define: it is called when a recording has been saved and checked, with aninfoobject about the file.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.drums.on()Listens to the drum machine from anywhere:OAVp5.drums.on('hit', fn)callsfnlikedrumHitdoes, and returns a function that stops listening.OAVp5.recordThe object behind the recording names: the state, the time, the last file, the formats this browser can write and the screenshot function.