File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Playing sounds Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Playing sounds" Watch "Playing sounds" New topic
Author

Playing sounds

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 712
Hello fellow javarians

I'm using eclipse, from inside eclipse I have an application.
I am able to load an audio clip using:

Then passing in the string "res/sounds/music.wav" for example.

But when I JAR the application, then place the JAR file on desktop alongside "res/sounds/music.wav", then it doesn't work.

Its annoying, because it works fine with the images, but not sounds.
Can anyone help?

Thanks very much!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35438
    
    9
Is the desktop part of the classpath? It seems that it must be, though, or it wouldn't work for images.


Android appsImageJ pluginsJava web charts
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 712
Yeh, I think it is. I can always execute jar files from desktop, or from within folders on the desktop.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35438
    
    9
That's not the same thing. It's perfectly possible to double-click and run jar files in a directory without the directory being in the classpath.

But since the mechanism used to load that wav file relies on the file being in the classpath, it's not going to work if the directory it's in now (the Desktop directory) is not in the classpath.

Using this mechanism for resources that are not in the jar file itself is error-prone for exactly this reason.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 712
Yeh, but I've tried putting resources in the jar file, that doesn't work either, or if it does, it will only work on my machine, or it wont work on a mac, or something annoying.

I give up
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 712
Ok, I saved the wav file "sounds/music.wav" in with jar file.
When I run the jar file from my desktop, sometimes the whole file will play, sometimes just a couple of seconds.

When I run the application from within eclipse it works perfectly.
Is there any way I can fix it so the sound works properly when I run the jar from my desktop?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Playing sounds
 
Similar Threads
Unable to configure tomcat 6.0 datasource from within eclipse.
Referencing XMLs from a runnable jar
table using lwuit in j2me
JAR FileNotFoundException
hot deployment refuses to work