I am pretty new to coding, I am trying to apply different seriously.js effects on different arrays of videos, I am not even able to make the program loop through the videos in the array
Here is the work https://editor.p5js.org/ogierpaul/sketches/EeYFA5Vq_
let vid1= 'footb1.mp4';
let vid2= 'footb3.mp4';
let vid3= 'futball1.mp4';
b = [];
b = [vid1,vid2,vid3];
function preload() {
for (var j = 0; j < b.length; j++){
q = createVideo(b[j]);
}
}
function setup() {
createCanvas(640,480, WEBGL);
}
function draw() {
background(220);
}
It looks like the fundamental thing you're misunderstanding here is how to add items to an array:
let vid1= 'footb1.mp4';
let vid2= 'footb3.mp4';
let vid3= 'futball1.mp4';
// I think you probably meant to declare q here not b
let q = []; // previously: b = [];
let b = [vid1,vid2,vid3];
function preload() {
for (var j = 0; j < b.length; j++){
// as you create each new video you need to add it to the q array
// you can do this using the push() function or using the index operator
q[j] = createVideo(b[j]);
// q.push(createVideo(b[j])); // this would also work
// What you had would not work: q = createVideo(b[j]);
// because it would replace the array initially stored in the variable q with
// a single video
}
}
function setup() {
createCanvas(640,480, WEBGL);
}
function draw() {
background(220);
}