Hey there,
I’m trying to make a simple music player with a selfdrawn animation in the background.
Animation and everything works fine, but the song keeps starting in the middle of it?
Is there a limit to the lenght of a song you can import?
While I’m at it, is there a way to stop the animation with a mouseclick or keypress?
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
Minim minim;
AudioPlayer player;
int numFrames = 41;
int currentFrame = 0;
PImage[] images = new PImage[numFrames];
void setup() {
size(1200,800);
frameRate(9);
for (int i = 0; i < numFrames; i++) {
String imageName = "phone" + nf(i, 3) + ".png";
images[i] = loadImage(imageName);
}
minim = new Minim (this);
// Audiodatei aus Data-Ordner laden
player = minim.loadFile ("Underwater.mp3");
// Audiodatei abspeilen
player.loop ();
player.shiftGain(-25.0, 25.0, 100000);
player.setGain(-20.0);
//player.setVolume(0.6);
}
void draw() {
currentFrame = (currentFrame+1) % numFrames; // Use % to cycle through frames
image(images[(currentFrame) % numFrames], 0, 0);
textSize(26);
text("Fallen Roses & Subsets", 10, 30);
fill(0);
text("Underwater (ft. Ayelle)", 400, 30);
fill(0);
float playPos = player.position ();
float playLen = player.length ();
float xpos = playPos / playLen * width;
// Zeichnen eines Kreises auf relativer Postition
// der Soundlänge gemappt auf die Fensterbreite
ellipse (xpos, height / 2, 20, 20);
}
void mousePressed(){
float pos = ((float) mouseX / width) * player.length();
// setzt neue Abspielposition
player.cue ((int) pos);
}
thanks in advance!
Ok, I cant figure out how to delete this, but i dont need help anymore.
for some reason my mp4 file was faulty even though it worked just fine outside of processing