Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Java Audio Clips(Where are audio clip files to be located.)
icon9.gif  Java Audio Clips [message #729647] Mon, 26 September 2011 17:24 Go to next message
Custer is currently offline CusterFriend
Messages: 8
Registered: September 2011
Junior Member
I am new to Eclipse and fairly new to Java. I'm trying to learn to develop Java on Eclipse by recreating some of my previous Java programs using Eclipse Indigo.
But I've encountered a problem. I can't load audio clips using getAudioClip(getDocumentBase(),"name of clip")); probably because I don't know where or how to place the clips in the Workspace. (I will probably have the same problem when I try to load images).
Can anyone help me with this?
Is there documentation somewhere that explains this?
Many Thanks, -C

Re: Java Audio Clips [message #729697 is a reply to message #729647] Mon, 26 September 2011 19:18 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
You can control the working directory you application runs in on the Arguments tab of the launch configuration (Run->Run Configurations)
Re: Java Audio Clips [message #729706 is a reply to message #729697] Mon, 26 September 2011 19:52 Go to previous messageGo to next message
Custer is currently offline CusterFriend
Messages: 8
Registered: September 2011
Junior Member
Thanks dpwegener-
Not sure I understand how that will solve the problem, but I appreciate the help and will give it try.
This particular program is an Applet not an Application. I usually put the audio and image files in the same folder as the applet's jar file. Don't know if that is what is appropriate when running it with Eclipse.
Re: Java Audio Clips [message #729809 is a reply to message #729706] Tue, 27 September 2011 02:39 Go to previous messageGo to next message
Custer is currently offline CusterFriend
Messages: 8
Registered: September 2011
Junior Member
dpwegener-
OK. I tried your suggestion but could not find anything that would make my applet work. I think I'm too much of a beginner here to understand what is needed.
Using Run As... causes the applet to run and display the proper program-generated objects in a window plus outputting my debugging comments to the console. However the sound clips do not play. My past experience says that this means the getAudioClip method did not find the clip files. Is this right?
Somewhere there must be some documentation/tutorial/suggestions that cover the use of Java applets, Eclipse and audio clips. Anyone???
Re: Java Audio Clips [message #729983 is a reply to message #729809] Tue, 27 September 2011 12:12 Go to previous messageGo to next message
daniel.coder.smith is currently offline daniel.coder.smithFriend
Messages: 18
Registered: September 2011
Junior Member
Can't you integrate the audio clip in the JAR file when deploying it? From what I know, Java stores it's resource files using a relative address with respect to it's main project directory. So, to use your audio files, place them in a folder /audio (for example) in the main directory, then call them with "play(getClass().getResource("audio/soundFile.au"));" or something like that. When you build the JAR it should also include the audio files too.

spring frame work

[Updated on: Tue, 13 December 2011 21:43]

Report message to a moderator

Re: Java Audio Clips [message #733824 is a reply to message #729983] Wed, 05 October 2011 18:06 Go to previous messageGo to next message
Custer is currently offline CusterFriend
Messages: 8
Registered: September 2011
Junior Member
Daniel-
Thank you for your response; I've been gone for a while and just read your post this morning.
I agree. That is exactly how I think it should work too.

Here is what I've been doing:
First, declare the audio clips as global variables => AudioClip METAL_SOUND, DRUM_SOUND, PIANO_SOUND;
Then load the clips in the init method, e.g. => DRUM_SOUND=getAudioClip(getDocumentBase(),"drums.aiff");
Finally, play the clip => DRUM_SOUND.play();

The clips are located in the package containing the .java files. I think the problem is that they should be located with the .jar. But - how do I do that? Do you know of any documentation that explains the proper method of adding audio clips and image files to an Eclipse project?
-C
Re: Java Audio Clips [message #733895 is a reply to message #733824] Wed, 05 October 2011 21:42 Go to previous messageGo to next message
Custer is currently offline CusterFriend
Messages: 8
Registered: September 2011
Junior Member
Daniel-
An added comment...
My posts may be a bit confusing; I'm actually having two closely related problems.

First, if I try to run my java applet from "inside" Eclipse using the "Run As..." command, it runs the code but does not create a .jar file. So, where should my audio clip files be located?

Second, I can use Eclipse's "File > Export" command to generate a .jar file (and thus have a logical home for the clip files); however, I can't seem to launch the jar. I have created a .html containing an <APPLET> tag as follows:
<APPLET> archive="FirstSwingApplet.jar" code="BasicSwingApplet" width=880 height=620>
Your browser does not support Java, so nothing is displayed.
</APPLET>
When opened in a browser, the html code runs but does not cause the applet to be run. Why?

Many thanks to anyone who can help me with understanding this.
-C
Re: Java Audio Clips [message #733921 is a reply to message #733895] Wed, 05 October 2011 23:53 Go to previous message
Custer is currently offline CusterFriend
Messages: 8
Registered: September 2011
Junior Member
To Whom It May Concern -
Just in case anyone else is having this problem, I've found a partial answer.
If you are using "Run As..." from the Run menu to try out your Java Applet, you can point to the applet class file using "getCodeBase()" which will take you the /bin folder. Put your audio files in here. Razz
Previous Topic:Is .metadata supposed to be under source control?
Next Topic:Reference on project in another project
Goto Forum:
  


Current Time: Tue Mar 19 07:33:01 GMT 2024

Powered by FUDForum. Page generated in 0.03936 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top