質問

Why didn't the SourceDataLine work when I export my project into JAR file?

I am working on a project to cope with AUDIO-DATA. Receive BYTE Stream in PCM format and transform these binary streams into the sound that can be heard. I use javax.sound.sampled.SourceDataLine to realize my requirements.

When I'm debugging the program in Eclipse, everthing goes well,but when I package all the codes and libs into a JAR file (Exactly, it's a RUNNABLE one which can run directly when double-clicked). I can not hear the sound. The data streams are received in a right way but the javax.sound.sampled.SourceDataLine doesn't work.

(My program interface is based on AWT (not swing),but I don't think this has anything to do with my problem)

役に立ちましたか?

解決

There are quite a few differences between the Eclipse environment and a jar file. In order to answer your question, we will need to know what your error messages you might be getting.

Common problem: file locations may not work because the OS file system does not apply to the inside of a jar. In this case, URL's are a better way to identify the resource file. There are also ways in which specifying the location of the resource can go awry, pertaining to how the relative vs absolute addressing is used. Some people also run into the mark/reset error when attempting to load a resource into an InputStream.

However, you are saying that the data IS getting loaded properly, but only the SourceDataLine is not working? I haven't run into those sorts of problems and I use Eclipse to develop programs with sound output frequently. Could you show some code, and let us know the OS environment? (For example, with some flavors of Linux, there can be contention problems over the output sound line.)

Also, without seeing anything, it is entirely possible that you have not set up the errors/exceptions to tell you if the input is failing in the jar form, and the output exists and consists of silence.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top