xxxxxxxxxx
27
// This is the second test of the p5LiveMedia webrtc library and associated service.
// Open this sketch up 2 times to send canvas video back and forth
let otherCanvas;
function setup() {
let myCanvas = createCanvas(400, 400);
let p5l = new p5LiveMedia(this, "CANVAS", myCanvas, "e4LTqKI8Q");
p5l.on('stream', gotStream);
}
function draw() {
background(220);
stroke(255);
fill(255,0,0);
ellipse(mouseX,mouseY,100,100);
// We could draw the otherCanvas here but then we would end up streaming that out as well.. It would get weeeeiiiiird like Al!
}
// We got a new stream!
function gotStream(stream) {
// This is just like a video/stream from createCapture(VIDEO)
otherCanvas = stream;
//otherCanvas.id is the unique identifier for this peer
//otherCanvas.hide();
}