open-audiovisual
搜尋 GitHub

oav-p5 參考 · 錄影與錄音

OAVp5.record.seconds#

變數oav-p5
OAVp5.record.seconds

正在錄的這一支已經錄了幾秒,錄完之後是那一支的長度。

當成跟著這一支錄影一起開始的時鐘:const t = recordingIsOn ? OAVp5.record.seconds : 0; 做出來的動畫,在影片裡一定從 0 開始。它是錄影開始之後的時間,不是草圖的時間,所以不包含 startRecording() 之前的那段。

型別
Number
範圍
0 …

一開始是 0,錄影中每秒更新四次。檔案存好之後是那一支的長度,下一支開始的時候又歸零。

範例

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);
  }
}
按 r:圓跳到最左邊,往右滑四秒,所以影片每次的開頭都一樣。

相關

  • recordingIsOn 現在有沒有在錄影。
  • OAVp5.record.state 錄影現在在哪個階段:'off'、'starting'、'on' 或 'saving'。
  • startRecording() 把畫布和草圖發出的聲音錄成一支影片檔,並回傳一個 promise,告訴你錄影有沒有開始。
  • OAVp5.record.last 最近一支存好的錄影的 info(跟 recordingSaved 拿到的是同一個物件),第一支之前是 null。

p5/oav-p5.js 第 1916 行

↑ 回到頂端 · 所有名稱