Minim bug: Null Pointer Exeption
in
Core Library Questions
•
5 months ago
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!
- import ddf.minim.*;
- AudioPlayer player;
- Minim minim;
- Lol[] ololo=new Lol[2];
- void setup()
- {
- size(512, 200);
- for(int i=0; i<2; i++){
- ololo[i]=new Lol();
- }
- minim = new Minim(this);
- player = minim.loadFile("groove.mp3");
- }
- void draw()
- {
- background(255);
- for(int i=0; i<2; i++){
- ololo[i].terminate();
- }
- }
- void stop()
- {
- player.close();
- minim.stop();
- super.stop();
- }
- void mousePressed() {
- player.play();
- }
- void mouseReleased()
- {
- player.close();
- player = minim.loadFile("groove.mp3");
- }
- class Lol{
- void terminate(){
- if(keyPressed){
- stop();
- }
- }
- }
1