recordingSaved()#
eventoav-p5function recordingSaved(info) {}
An event you define: it is called when a recording has been saved and checked, with an info object about the file.
Define function recordingSaved(info) { … } to know when the file is done: stopRecording() or the end of seconds leads to it. By then the file has already been handed to the browser to download. The same info is given to the promise of stopRecording() and to OAVp5.record.on('saved', fn), and stays in OAVp5.record.last.
info.url works as a link to the file (createA(info.url, 'play') or a <video>) until a minute after the next take is saved. warnings is what the card after the take says in words; an empty list means nothing looked wrong.
Parameters
| Name | Type | Description |
|---|---|---|
info | Object | name (the file name), format ('mp4' or 'webm'), type (the exact MIME type), seconds (length, to a tenth), bytes, width and height (even numbers for MP4), fps, audio (the video has a sound track), heard (something sounded), sources (which sounds were in it: 'sound', 'drums', 'mic', 'p5sound'), warnings (what looked wrong: 'recEmpty', 'recWebm', 'recNoAudio', 'recSilent', 'recBlack', usually an empty list), blob (the file) and url (an address for the blob). |
Examples
let saved = '';
function setup() {
createCanvas(400, 300);
}
function keyPressed() {
if (key === 'r') startRecording(3);
}
function recordingSaved(info) {
saved = info.name + ' ' + info.format + ' ' + info.seconds + ' s ' + round(info.bytes / 1024) + ' KB';
}
function draw() {
background(20);
circle(200 + sin(frameCount * 0.05) * 120, 150, 50);
if (!recordingIsOn) {
fill(255);
text(saved || 'press r to record 3 seconds', 20, 30);
}
}let note = '';
function setup() {
createCanvas(400, 300);
startDrums('breakbeat', 120);
}
function keyPressed() {
if (key === 'r') startRecording(4);
}
function recordingSaved(info) {
note = info.heard ? 'with sound: ' + info.sources.join(', ') : 'silent: click the page before you record';
if (info.warnings.length) note += ' (' + info.warnings.join(', ') + ')';
}
function draw() {
background(20);
fill(255);
if (!recordingIsOn) text(note || 'click once, then press r', 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.stopRecording()Stops the recording; the video is finished, downloaded, and handed torecordingSaved(info)and to the returned promise.OAVp5.record.lastTheinfoof the last recording that was saved (the same objectrecordingSavedgot), ornullbefore the first one.OAVp5.record.on()Listens to the recording from anywhere:OAVp5.record.on('saved', fn)oron('start', fn), and it returns a function that stops listening.recordingIsOnWhether a recording is running right now.