Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mic;
- var vid1;
- var vid2;
- function setup(){
- createCanvas(windowWidth, windowHeight);
- vid1 = createVideo("Comp_1.mp4");
- vid1.hide();
- vid1.loop();
- vid2 = createVideo("Comp_2.mp4");
- vid2.hide();
- // vid2.loop();
- mic = new p5.AudioIn()
- mic.start();
- }
- let secondPlaying = false;
- function draw(){
- background(200);
- micLevel = mic.getLevel();
- console.log(micLevel);
- if(micLevel>=0.2){
- secondPlaying = true;
- vid2.play();
- }
- if(secondPlaying){
- image(vid2, 0, 0);
- }
- else{
- image(vid1,0,0);
- }
- if(secondPlaying && vid2.ended){
- secondPlaying = false;
- }
- }
Add Comment
Please, Sign In to add comment