Hi…I searched the site and found another code that works correctly.
Now I have another problem:
When I create object from blow class and send the address of audio to its constructor, I have to send the complete address like:
“C:\Documents and Settings\TheHero\My Documents\NetBeansProjects\project1\src\project1\s1.wav”
But I want to use this code just with name of sound like : “s1.wav”.
I copied the sound into the src folder and then use “s1.wav” and the result was ”java.io.FileNotFoundException”.
If I use complete address of sound, when I run the program on another computer it does not work. I’m right?
//****************************
public class MusicPlayer {
private String filename;
public MusicPlayer(String filename) {
this.filename = filename;
}
public void play() {
try {
InputStream in = new FileInputStream(filename);
AudioStream as = new AudioStream(in);
AudioPlayer.player.start(as);
} catch (IOException e) {
e.printStackTrace();
}
}
//************************
I have the same problem with images. When I use these codes, I must use complete address of image
File input = new File(imageName);
image = ImageIO.read(input);
Please Someone help me!I really need these! Thank you all guys….