Guest User

Untitled

a guest
Feb 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. var mic;
  2. var vid1;
  3. var vid2;
  4.  
  5. function setup(){
  6. createCanvas(windowWidth, windowHeight);
  7. vid1 = createVideo("Comp_1.mp4");
  8. vid1.hide();
  9. vid1.loop();
  10. vid2 = createVideo("Comp_2.mp4");
  11. vid2.hide();
  12. // vid2.loop();
  13. mic = new p5.AudioIn()
  14. mic.start();
  15. }
  16.  
  17. let secondPlaying = false;
  18. function draw(){
  19. background(200);
  20. micLevel = mic.getLevel();
  21. console.log(micLevel);
  22. if(micLevel>=0.2){
  23. secondPlaying = true;
  24. vid2.play();
  25. }
  26. if(secondPlaying){
  27. image(vid2, 0, 0);
  28. }
  29. else{
  30. image(vid1,0,0);
  31. }
  32.  
  33. if(secondPlaying && vid2.ended){
  34. secondPlaying = false;
  35. }
  36. }
Add Comment
Please, Sign In to add comment