16/01/12 8:03
Bonny
import javax.media.*;
import java.io.*;
public class Myplayer {
private static Player audioPlayer = null;
private static File f = null;
public static void play(File fx) throws IOException, NoPlayerException, CannotRealizeException {
f = fx;
audioPlayer = Manager.createRealizedPlayer(f.toURL());
audioPlayer.start();
}
public static void stop() {
audioPlayer.stop();
audioPlayer.close();
}
public static long duration() {
return ((long) audioPlayer.getDuration().getSeconds()) * (long) Math.pow(10, 3);
}
public static void deallocate() {
audioPlayer.deallocate();
}
public static void main(String[] args) {
try {
Myplayer.play(new File("path://primo_file.mp3"));
Thread.sleep(Myplayer.duration());
Myplayer.stop();
Myplayer.deallocate();
Myplayer.play(new File("path://secondo_file.mp3"));
Thread.sleep(Myplayer.duration());
Myplayer.stop();
Myplayer.deallocate();
}catch(Exception e){}
}
}
Però non so come gestire la pausa o |>> e <<|
Ultima modifica effettuata da Bonny 16/01/12 8:05
aaa