Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

HELP! How to play different audio files in one sketch?

$
0
0

Hey guys, On one hand, I'm trying to play 10 different audio files in one sketch with minim. On the other hand, I need the program to ignore every following mouse press if the player is playing until its done. However, I dont get how to set up the "false" command. I would be so happy if someone could take a look at my sketch and help me out! Thanks a lot.

import ddf.minim.*;

Minim minim;
AudioPlayer[] player;

String[] SONGS = {"Fact01.mp3", "Fact02.mp3", "Fact04.mp3", "Fact05.mp3", "Fact06.mp3", "Fact07.mp3", "Fact08.mp3", "Fact09.mp3", "Fact10.mp3"};

void setup() {
  size(200, 200, P3D);
  minim = new Minim(this);
    player= new AudioPlayer[10];

  for (int i=0; i<SONGS.length; i++) {
    player[i] = minim.loadFile(SONGS[i]);
  }
}

void draw() {
  background(0);
}

void mousePressed() {

  if(player.isPlaying()==false){
  }

  int v=int(random(SONGS.length));
  player[v].rewind();
  player[v].play();

Viewing all articles
Browse latest Browse all 2896

Trending Articles