how to read .wma song file in java. I'm using this code. but this code is error.
(Error == javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file )
private void playAudio() {
try {
File soundFile =
new File("Track_1.wma");
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
audioFormat = audioInputStream.getFormat();
System.out.println(audioFormat);
DataLine.Info dataLineInfo =
new DataLine.Info(
SourceDataLine.class,
audioFormat);
sourceDataLine =
(SourceDataLine) AudioSystem.getLine(
dataLineInfo);
new PlayThread().start();
} catch (Exception e) {
e.printStackTrace();
}
}
class PlayThread extends Thread {
byte tempBuffer[] = new byte[10000];
public void run() {
try {
sourceDataLine.open(audioFormat);
sourceDataLine.start();
int cnt;
while ((cnt = audioInputStream.read(
tempBuffer, 0, tempBuffer.length)) != -1
&& stopPlayback == false) {
if (cnt > 0) {
sourceDataLine.write(
tempBuffer, 0, cnt);
}
}
sourceDataLine.drain();
sourceDataLine.close();
} catch (Exception e) {
e.printStackTrace();
}
Please help me.
Thanks.