Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Minim bug: Null Pointer Exeption

$
0
0
What my code does: it plays an audio file when mouse is pressed and stops when it's released. 
I also have an array of objects, each of which has a function that stops Minim object when a key is pressed.
If I run it - I get NullPointerExeption. But whaen there's only one object - it works fine.
Why is it and how to fix it? Thanks in advance!
  1. import ddf.minim.*;

  2. AudioPlayer player;
  3. Minim minim;
  4. Lol[] ololo=new Lol[2];

  5. void setup()
  6. {
  7.   size(512, 200);
  8.   for(int i=0; i<2; i++){
  9.   ololo[i]=new Lol();
  10.   }
  11.   minim = new Minim(this);
  12.   player = minim.loadFile("groove.mp3");
  13. }

  14. void draw()
  15. {
  16.   background(255);
  17.   for(int i=0; i<2; i++){
  18.    ololo[i].terminate(); 
  19.   }
  20. }

  21. void stop()
  22. {
  23.   player.close();
  24.   minim.stop();
  25.   super.stop();
  26. }

  27. void mousePressed() {
  28.     player.play();
  29.  }

  30. void mouseReleased()
  31. {
  32.   player.close();
  33.   player = minim.loadFile("groove.mp3");
  34. }

  35. class Lol{
  36. void terminate(){
  37. if(keyPressed){
  38.   stop(); 
  39. }
  40. }
  41. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles