this.fileName = fileName;
}
}
public static void main(String[] args) throws IOException, InterruptedException {
StreamingDataHandler sdh = null;
InputStream is = null;
try {
System.out.println("Choose genre to start audio streaming:");
Composition chosen;
do {
for (Composition c : Composition.values()) {
System.out.println(String.format("%d. %s", c.id, c.genre));
}
int chosenId = new Scanner(System.in).nextInt();
chosen = Composition.getById(chosenId);
if (chosen == null) {
System.out.println("\n\nIncorrect choice. Please select a proper number in range:");
}
} while (chosen == null);
System.out.println(String.format("\n\nLoading %s - %s :\n\n", chosen.artist, chosen.songTitle));
System.out.println("Creating and configuring stream service reference... ");
provider.AudioStreamerService service = new provider.AudioStreamerService();
provider.AudioStreamer port = service.getAudioStreamerPort();
System.out.println("DONE\nGeting data handler... ");
sdh = (StreamingDataHandler) port.getWavStream(chosen.fileName);
System.out.println("DONE\nOpening data stream... ");
is = sdh.readOnce();
System.out.println("DONE\nStarting audio player thread... ");
sun.audio.AudioPlayer.player.start(is);
System.out.println("Audio player thread started, waiting for it to finish... ");
sun.audio.AudioPlayer.player.join();
System.out.println("DONE");
} finally {
System.out.println("Closing data streams... ");
is.close();
sdh.close();
System.out.println("DONE");
}
}