0

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();
  }
  • How do you know if it's shuffling or not? Post the code which makes you able to differentiate this and there probably lies the answer. – laancelot Oct 18 '20 at 06:27
  • I know its shuffling because the print statement shows up before and after it. I keep getting this ==== JavaSound Minim Error ==== ==== Don't know the ID3 code APIC. I looked it up and someone said it has to do with not finding mp3 file but I don't think thats the problem since it was able to find it for my play and pause buttons. @laancelot –  Oct 18 '20 at 06:28
  • Then why do you say that "nothing happens"? What should happen, how and why? – laancelot Oct 18 '20 at 06:31
  • I have a list of songs which should be shuffled and the picked song should be played. For example if a song is playing and user clicks shuffle the one playing should stop and the new song from the shuffle should play. If nothing is playing and they hit shuffle, the song from the shuffle should play. Either way, whenever they click shuffle, something from my list should be picked, whatever is playing should stop, and the song that is picked from the shuffle should play. @laancelot –  Oct 18 '20 at 06:32
  • Oh nevermind, I just got the entire comment. Do you have a `draw()` method (with something in it)? – laancelot Oct 18 '20 at 06:34
  • Also the parts of your code dealing with sound would be a nice read. – laancelot Oct 18 '20 at 06:34
  • Please check question, I updated with other code. I added what I have in draw() and outside of it. @laancelot –  Oct 18 '20 at 06:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/223228/discussion-between-laancelot-and-charmy). – laancelot Oct 18 '20 at 06:41

1 Answers1

0

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

MLast
  • 60
  • 7