Re: Sound i Java Application
Quote:
What am I doing wrong and how I can "fix" it?
Whenever you call a method, you need to prefix the method name with an object or a class name.
object.playSound();
or
ClassName.playSound(); // for a static method
The only time that you could call a method without prefixing it with an object or a class name is if you defined that method in the current class which isn't the case here.
I did get the following code to work:
Code:
import sun.audio.*; //import the sun.audio package
import java.io.*;
public class Sounds {
public static void main(String[] args) throws IOException {
// Open an input stream to the audio file.
InputStream in = new FileInputStream("pop.wav");
// Create an AudioStream object from the input stream.
AudioStream as = new AudioStream(in);
// Use the static class member "player" from class AudioPlayer to play clip.
AudioPlayer.player.start(as);
}
}
Re: Sound i Java Application
Thanks a lot man, it works!!!
//ech, not works ;/
Code:
AudioStream is internal proprietary API and may be removed in a future release
AudioStream as = new AudioStream(in);