• Create Account

### #Actualmedv4380

Posted 13 January 2012 - 04:19 PM

First thing is to strip out that Applet code you have sitting their. It's the culprit in catching the errors so you don't see them. Which makes since because Applets were intended to access data only from a web server and never from the client side machine so it should have been made to handle the errors a little and expect that the audio isn't always there. Try something more like this.

import com.sun.media.sound.JavaSoundAudioClip;
import java.io.File;
import java.io.FileInputStream;
public class Test {
public static void main(String args[]) {
File f = null;
FileInputStream in;
try {
f = new File("C:\\AudioTestFolder\\WindowsBalloon.wav");
//mario.mid
//WindowsBalloon.wav
in = new FileInputStream(f);
JavaSoundAudioClip ac = new JavaSoundAudioClip(in);
ac.play();
} catch (java.io.IOException e) {
System.out.println("IO Exception in: " + f.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
}


This code actually throws errors so you can get better information on what's happening. I'm honestly getting the same issue with the WindowsBalloon.wav that comes with Windows 7, but it works fine with the mario.mid.

The error is
java.io.IOException: Unable to create AudioClip from input stream
at com.sun.media.sound.JavaSoundAudioClip.<init>(JavaSoundAudioClip.java:114)
at Test.main

But if the file name is wrong the error is this
java.io.FileNotFoundException: C:\XXX\Windows Balloon.wav (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at Test.main


If you're getting the first error you might try encoding the wav file and try something a little more primitive in the wave settings.

What's occurring is Java is trying to use some native code in order to play the file. If some assumptions that the native code is making about the OS is in fact wrong then it will fail. In fact the "Source Code" for where your error is most likely occuring at looks like this.

	private boolean createSourceDataLine() {
//compiled code
throw new RuntimeException("Compiled Code");
}


Which was Sun's way of say Good Luck if this doesn't work.

Like I said before the Sound API is neglected so it tends to have some odd side effects.

I bet you that ether your boss maybe running ether a different OS or a different JVM. There is the possibility of him having the same OS and JVM and then the cause would be a tiny difference in the Audio Drivers he has loaded vs the ones you have loaded, but I doubt that is the case.

PS
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6251460
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5070730

The bug you're probably hitting has been around sing Java 1.4 and I tested it with 1.6 and 1.7 and they are still there so its been known about for a long time and has yet to really be fixed.

### #2medv4380

Posted 13 January 2012 - 10:56 AM

First thing is to strip out that Applet code you have sitting their. It's the culprit in catching the errors so you don't see them. Which makes since because Applets were intended to access data only from a web server and never from the client side machine so it should have been made to handle the errors a little and expect that the audio isn't always there. Try something more like this.

import com.sun.media.sound.JavaSoundAudioClip;
import java.io.File;
import java.io.FileInputStream;
public class Test {
public static void main(String args[]) {
File f = null;
FileInputStream in;
try {
f = new File("C:\\AudioTestFolder\\WindowsBalloon.wav");
//mario.mid
//WindowsBalloon.wav
in = new FileInputStream(f);
JavaSoundAudioClip ac = new JavaSoundAudioClip(in);
ac.play();
} catch (java.io.IOException e) {
System.out.println("IO Exception in: " + f.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
}


This code actually throws errors so you can get better information on what's happening. I'm honestly getting the same issue with the WindowsBalloon.wav that comes with Windows 7, but it works fine with the mario.mid.

The error is
java.io.IOException: Unable to create AudioClip from input stream
at com.sun.media.sound.JavaSoundAudioClip.<init>(JavaSoundAudioClip.java:114)
at Test.main

But if the file name is wrong the error is this
java.io.FileNotFoundException: C:\XXX\Windows Balloon.wav (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at Test.main


If you're getting the first error you might try encoding the wav file and try something a little more primitive in the wave settings.

What's occurring is Java is trying to use some native code in order to play the file. If some assumptions that the native code is making about the OS is in fact wrong then it will fail. In fact the "Source Code" for where your error is most likely occuring at looks like this.

	private boolean createSourceDataLine() {
//compiled code
throw new RuntimeException("Compiled Code");
}


Which was Sun's way of say Good Luck if this doesn't work.

Like I said before the Sound API is neglected so it tends to have some odd side effects.

I bet you that ether your boss maybe running ether a different OS or a different JVM. There is the possibility of him having the same OS and JVM and then the cause would be a tiny difference in the Audio Drivers he has loaded vs the ones you have loaded, but I doubt that is the case.

### #1medv4380

Posted 13 January 2012 - 10:55 AM

First thing is to strip out that Applet code you have sitting their. It's the culprit in catching the errors so you don't see them. Which makes since because Applets were intended to access data only from a web server and never from the client side machine so it should have been made to handle the errors a little and expect that the audio isn't always there. Try something more like this.

import com.sun.media.sound.JavaSoundAudioClip;
import java.io.File;
import java.io.FileInputStream;
public class Test {
public static void main(String args[]) {
File f = null;
FileInputStream in;
try {
f = new File("C:\\AudioTestFolder\\WindowsBalloon.wav");
//mario.mid
//WindowsBalloon.wav
in = new FileInputStream(f);
JavaSoundAudioClip ac = new JavaSoundAudioClip(in);
ac.play();
} catch (java.io.IOException e) {
System.out.println("IO Exception in: " + f.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
}


This code actually throws errors so you can get better information on what's happening. I'm honestly getting the same issue with the WindowsBalloon.wav that comes with Windows 7, but it works fine with the mario.mid.

The error is
java.io.IOException: Unable to create AudioClip from input stream
at com.sun.media.sound.JavaSoundAudioClip.<init>(JavaSoundAudioClip.java:114)
at Test.main

But if the file name is wrong the error is this
java.io.FileNotFoundException: C:\Ci3\Windows Balloon.wav (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at Test.main


If you're getting the first error you might try encoding the wav file and try something a little more primitive in the wave settings.

What's occurring is Java is trying to use some native code in order to play the file. If some assumptions that the native code is making about the OS is in fact wrong then it will fail. In fact the "Source Code" for where your error is most likely occuring at looks like this.

    private boolean createSourceDataLine() {
//compiled code
throw new RuntimeException("Compiled Code");
}


Which was Sun's way of say Good Luck if this doesn't work.

Like I said before the Sound API is neglected so it tends to have some odd side effects.

I bet you that ether your boss maybe running ether a different OS or a different JVM. There is the possibility of him having the same OS and JVM and then the cause would be a tiny difference in the Audio Drivers he has loaded vs the ones you have loaded, but I doubt that is the case.

PARTNERS