Playing audio files from a playlist with Minin

edited March 2018 in Library Questions

I have an application where audio ques are selected from a playlist (array). Minin has an example of just playing a single file. I am confused on how to declare and setup these file arrays. Which variable has the arry? Can you point me to an example? Thanks

Answers

  • Answer ✓

    Can you post your entire code please?

  • Actually, I had no code when I originally posted, but was asking a programming question. However, I have since answered my own question with the following demonstration code.

    This sketch demonstrates how to play a file playlist with Minim using an AudioPlayer. It is based on the PlayAFile example from Minin. The array index i is hardcoded for this demo code.

    import ddf.minim.*;

    Minim minim; AudioPlayer[] player=new AudioPlayer[3];

    int i=0

    void setup(){

    size(512, 200);
    minim = new Minim(this);
    player[0] = minim.loadFile("groove.mp3");

    player[1] = minim.loadFile(“bad_boy2.wav");

    player[2] = minim.loadFile("Jack.wav"); }

    void draw(){

    background(0);

    stroke(255);

    if ( player[i].isPlaying() ) {

    text("Press any key to pause playback.", 10, 20 );
    

    }

    else{

    text("Press any key to start playback.", 10, 20 );
    

    }

    }

    void keyPressed(){

    if ( player[i].isPlaying() ){

    player[i].pause();
    

    }

    else if ( player[i].position() == player[i].length() ) {

    player[i].rewind();
    
    player[i].play();
    

    }

    else {

    player[i].play();
    

    }

    }

  • Answer ✓

    well done!

Sign In or Register to comment.