I am trying without success to play an mp3 using the following code (Java2). I get 3 warnings but no errors. What did I do wrong? Any assistence will be appreciated.
Warnings:
Code:warning: sun.audio.AudioStream is Sun proprietary API and may be removed in a future release
Code:// Program 3 - playing sound clips import sun.audio.*; // imports the sun.audio package import java.io.*; import javax.swing.*; public class game1 { public void playSound() { try { JOptionPane.showMessageDialog(null,"Inside the try catch block"); //Open an input stream to the audio file. InputStream in = new FileInputStream("nightingale2"); //Create an Audio stream object from the input stream AudioStream as = new AudioStream(in); AudioPlayer.player.start(as); //AudioPlayer.player.stop(as); }// end try catch (Exception e) { JOptionPane.showMessageDialog(null, "Something is wrong"); } } public static void main( String arg[] ) { game1 g = new game1(); g.playSound(); } }




Reply With Quote