John John - 21 days ago 9
Java Question

JACo mp3 Player

import jaco.mp3.player.MP3Player;
import java.io.File;

public class Test {

public static void main(String[] args) {

try{
File f = new File ("001.mp3");
MP3Player mp3 = new MP3Player(f);
mp3.play();
}
catch(Exception e){System.err.println(e);}
}
}


It plays the first second only then stops, I tried many different mp3 files but still the same problem.

Answer

My impression is that the mp3 player is shutted down because the java program terminates his execution. You could try hanging the java thread with a sleep. This should works:

try{
  File f = new File ("001.mp3");  
  MP3Player mp3 = new MP3Player(f);
  mp3.play();
  while(!mp3.isStopped()){
    Thread.sleep(5000);
  }
}
catch(Exception e){
System.err.println(e);
}
Comments