xxxxxxxxxx
35
let myVideo;
let otherVideo;
let liveMediaConnection;
function setup() {
createCanvas(600, 300);
liveMediaConnection = new p5LiveMedia(this, null, null, "my-cool-room");
liveMediaConnection.on("stream", gotStream);
myVideo = createCapture(VIDEO, gotLocalMediaStream);
myVideo.muted = true;
myVideo.hide();
}
function gotLocalMediaStream (stream) {
console.log("got local stream!");
liveMediaConnection.addStream(stream, "CAPTURE");
};
// We got a new stream!
function gotStream(stream, id) {
console.log('got remote stream!');
// This is just like a video/stream from createCapture(VIDEO)
otherVideo = stream;
//otherVideo.id and id are the same and unique identifiers
// otherVideo.hide();
}
function draw() {
background(220);
if (otherVideo){
image(otherVideo,50,50,50,50);
}
}