Songs not shuffling for button - Processing

68 views Asked by At

I have a shuffle button image that I'm using an an actual button. If the user 'clicks' on this image, the current song playing (if there is one) should stop playing and a random song from my list should play. If there is no song play, you would still play a random song from the list. I'm having trouble with this 'button' because the song isn't shuffling at all, infact nothing happens at all. I've used this same technique with 2 other buttons and had no problems so I think it may be the way I'm calling this method but I'm not sure what I'm doing wrong. I put in a print statement and shuffling... only prints once so I know it works but no songs are shuffling. Does anyone know what I could be doing wrong?

//Image for shuffle button
    imageMode(CORNER);
    image(shuffle, 140, 15, 50, 50); 

void shufflePlayList() {
  current=0;
  tableau.shuffle();
}


//Shuffle button
  if(mouseX > 140 && mouseX < 190 && mouseY > 15 && mouseY < 65){ 
     println("shuffling...");
    shufflePlayList();
  }
1

There are 1 answers

0
MLast On

The conditional only checks whether the mouse is within a certain area not if the button is clicked. so it will run every frame (providing it is within the draw function) if you're hovering over it