xxxxxxxxxx
22
let videoElement;
function setup() {
createCanvas(800, 600); // Create your p5.js canvas
// Create a YouTube iframe using the createElement function
videoElement = createElement('iframe');
videoElement.attribute('width', '560');
videoElement.attribute('height', '315');
videoElement.attribute('src', 'https://www.youtube.com/embed/0EqSXDwTq6U?si=dxlnQ-uApNXprjQd');
videoElement.attribute('frameborder', '0');
videoElement.attribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture');
videoElement.attribute('allowfullscreen', true);
// Position and size the iframe on the canvas
videoElement.position(100, 100); // Place the iframe at (100, 100)
}
function draw() {
background(200); // Set background color
text('Here is your YouTube video:', 50, 50); // Add text above the video
}