you can use this code:
(change to AudioSnippet which gives you more info about its status)
(change to AudioSnippet which gives you more info about its status)
- import ddf.minim.spi.*;
- import ddf.minim.signals.*;
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- import ddf.minim.ugens.*;
- import ddf.minim.effects.*;
- Minim minim;
- AudioSnippet alert;
- boolean hault;
- boolean donePlaying=false;
- float elapsedTime=0;
- void setup() {
- size(310, 220);
- fill(50);
- textSize(30);
- text("PABLO", 105, 50);
- textSize(20);
- text("Press 'H' to hault Program", 25, 100);
- // Sound Output Setup
- minim = new Minim(this);
- alert = minim.loadSnippet("siren.mp3");
- }
- void draw() {
- if(hault&&!alert.isPlaying())
- {
- hault = false; //although you don't need to change the value of halt
- //(unless you want to write its state to a file before exitting)
- //noLoop(); //and you don't need this, exit() stops the loop
- exit();
- }
- }
- void keyPressed() {
- if (key == 'h') {
- hault = true;
- alert.play();
- }
- }