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

Trying to make a thread sleep (minim)

$
0
0
Hello everyone!
Im quite new to Processing, and im currently experimenting with the minim lib.
The issue is that i want to load the audi files into an array and play them one after one. But the audio was playing all at once.
At the moment im trying to make the thread sleep but without any luck ("Unhandled exception type Interrupted Exception").

Any suggestion on what i could do?

  1. import ddf.minim.*; //Minim library
  2. import ddf.minim.analysis.*;

  3. Minim minim; 
  4. AudioPlayer player[]; //Player array

  5. //-----------------------------------------------------------------------------------
  6.  
  7. void setup() {

  8.   minim = new Minim(this); 
  9.   player = new AudioPlayer[8]; //setup Array
  10.   int i = 1;

  11.     //Getting the Audio     
  12.    while(i<8){
  13.     player[i] = minim.loadFile(i + ".mp3");
  14.   
  15.   player[i].play();
  16.   
  17.   //Trying to stop it
  18.   while(player[i].isPlaying()){
  19.   
  20.     Thread.sleep(player[i].length());
  21.    } 
  22.     i++;
  23.   }

  24.   } 
  25. //---------------------------------------------------------------------------------------
  26.     


Viewing all articles
Browse latest Browse all 1768

Trending Articles