We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Ok, so I'm pretty new to this, but for my code I want to make images & audio play on key press. I can get this to work, but when you press a different key and then press back to the original key - the image plays, but not the audio. Any suggestions to make audio re-play each time that key is pressed? Any help would be greatly appreciated!
Working on a mac, processing 2.0, images are 1440 x 856
Here's my code:
import ddf.minim.*;
Minim minim;
AudioPlayer player1; 
AudioPlayer player2;
AudioPlayer player3;
boolean square1 = false;
boolean square2 = false;
boolean square3 = false;
PImage img;
PImage img1;
PImage img2;
PImage img3;
void setup() {
  size (1440, 856);
  img = loadImage("d.jpg");
  background(img);
  minim = new Minim(this);
  player1 = minim.loadFile("1.mp3");
  player2 = minim.loadFile("2.mp3");
  player3 = minim.loadFile("3.mp3");
}
void draw(){
  if(square1 == false && keyCode == LEFT ){
    img1 = loadImage("a.jpg");
    image(img1,0,0);
    player1.play();
    square1=true;
    square2=false;
    square3=false;
  }
  if(square2 == false && keyCode == RIGHT ){
    img2 = loadImage("b.jpg");
    image(img2,0,0);
    player2.play();
    square1=false;
    square2=true;
    square3=false;
  }
    if (keyPressed) {
    if (key == 'w' || key == 'W'){
    img3 = loadImage("c.jpg");
    image(img3,0,0);
    player3.play();
    square1=false;
    square2=false;
    square3=false;
    square4=true;
  }
    }
}
void stop()
{
  minim.stop();
  super.stop();
}
Answers
player1.rewind();
player1.play();
That worked perfectly! Thank you so much ybakos!
I'm having the same problem except it's a video I want to rewind. I tried doing
mov1.rewind(); mov1.play();
but it doesn't work. I'm very new to this!
http://processing.org/reference/libraries/video/index.html