package crazyOrb.musikplayer;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.AudioDevice;
import javazoom.jl.player.FactoryRegistry;
import javazoom.jl.player.advanced.AdvancedPlayer;
/**
*
* @author Daniel
*/
public class Soundplayer {
PlayList playList = new PlayList();
AdvancedPlayer player;
InputStream input;
AudioDevice device;
public boolean setTrack(String trackTitle) {
try {
input = this.getClass().getResourceAsStream(playList.getPath(trackTitle));
BufferedInputStream in = new BufferedInputStream(this.input);
device = FactoryRegistry.systemRegistry().createAudioDevice();
this.player = new AdvancedPlayer(in, device);
} catch (JavaLayerException ex) {
Logger.getLogger(MPmitMP3.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
return true;
}
public void play(){
try {
player.play();
} catch (JavaLayerException ex) {
Logger.getLogger(Soundplayer.class.getName()).log(Level.SEVERE, null, ex);
}
}
public ArrayList<String> getTrackPaths() {
return playList.getTrackPaths();
}
public ArrayList<String> getTracks() {
return playList.getTrackNames();
}
}