public void play(String filename) {
// Instantiate BasicPlayer.
BasicPlayer player = new BasicPlayer();
// BasicPlayer is a BasicController.
BasicController control = (BasicController) player;
// Register BasicPlayerTest to BasicPlayerListener events.
// It means that this object will be notified on BasicPlayer
// events such as : opened(...), progress(...), stateUpdated(...)
player.addBasicPlayerListener(this);
try { // Open file, or URL or Stream (shoutcast, icecast) to play.
control.open(new File(filename));
// control.open(new URL("http://yourshoutcastserver.com:8000"));
// Start playback in a thread. control.play();
// If you want to pause/resume/pause the played file then
// write a Swing player and just call control.pause(),
// control.resume() or control.stop().
// Use control.seek(bytesToSkip) to seek file
// (i.e. fast forward and rewind). seek feature will
// work only if underlying JavaSound SPI implements
// skip(...). True for MP3SPI and SUN SPI's
// (WAVE, AU, AIFF). // Set Volume (0 to 1.0). control.setGain(0.85);
// Set Pan (-1.0 to 1.0).
control.setPan(0.0);
control.play();
} catch (BasicPlayerException e) {
e.printStackTrace();
}
}