You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
941 B
JavaScript

1 year ago
let y = 0;
let myVideo;
let otherVideo;
function setup() {
createCanvas(windowHeight, windowWidth,WEBGL);
let constraints = {audio: true, video: true};
myVideo = createCapture(constraints,
function(stream) {
let p5l = new p5LiveMedia(this, "CAPTURE", stream, "NYAMST")
p5l.on('stream', gotStream);
}
);
myVideo.elt.muted = true;
myVideo.hide();
}
function draw() {
background(0);
strokeWeight(3);
translate(-200,-90)
texture(myVideo);
circle(0, 0, 300);
if (otherVideo) {
blend(otherVideo, 0, 0, otherVideo.width, otherVideo.height, 0, 0, width, height, MULTIPLY);
strokeWeight(3);
translate(-400,-90)
texture(otherVideo);
circle(0, 0, 300);
}
}
// We got a new stream!
function gotStream(stream, id) {
// This is just like a video/stream from createCapture(VIDEO)
otherVideo = stream;
//otherVideo.id and id are the same and unique identifiers
otherVideo.hide();
}