PLAYING SOUND WITHOUT JApplet
Hi there,
I'm a new member in Java Developer forums, I hope that I'll be an effective member..
for now I need help with java sound , multimedia
I'm developing a program that part of it is to play array of sounds (Not JApplet) I tried to use the function AudioClip(getClass().getResources("soundName.wav"); but it works only with JApplet
I want to play the sound without JApplet
I found that there is a package called javax.swing.sound.*;
but syntax error occured in my program.. that this package does not exist..
Please help me..
[585 byte] By [
compumana] at [2007-10-3 11:53:40]

Here is a sample. I run it in standalone
public class Music
{
public static void main(java.lang.String[] args)
{
java.applet.AudioClip sound = null;
try
{
String userdir= System.getProperties().getProperty("user.dir") ;
java.io.File myfile = new java.io.File("mymusic.mp3");
java.net.URI uri = myfile.toURI();
sound = java.applet.Applet.newAudioClip(uri.toURL());
sound.play();
}
catch (Exception io){/* on ne fait iren si cela ne marche pas*/ }
}
I am also having the same problem. I couldn't get sound to work with the applet based one. I have the below code, it compiles and when you run the program it runs the length of the audio file but there is no sound? Is there something missing?
import sun.audio.*;//import the sun.audio package
import java.io.*;
public class sound{
public static void main (String args[])
{
try
{
InputStream in = new FileInputStream("cows2.au");
AudioStream as = new AudioStream(in);
AudioPlayer.player.start(as);
AudioPlayer.player.stop(as);
}
catch (Exception e)
{
System.out.println("Failed");
}
}
} //end class
Message was edited by:
Lisa_g