[RESOLVED] Sound not working
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:
Quote:
warning: sun.audio.AudioStream is Sun proprietary API and may be removed in a future release
Code:
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();
}
}
Re: [RESOLVED] Sound not working
Re: [RESOLVED] Sound not working
Justa Lol, thank you for the link the information was very clear and straight forward
Re: [RESOLVED] Sound not working
Quote:
Originally Posted by Justa Lol
I followed the instructions but I got the following errors:
Quote:
--------------------Configuration: <Default>--------------------
java:24: package javazoom.jl.player does not exist
import javazoom.jl.player.Player;
^
java:29: cannot find symbol
symbol : class Player
location: class Sound
private Player player;
^
java:43: cannot find symbol
symbol : class Player
location: class Sound
player = new Player(bis);
^
java:67: cannot find symbol
symbol : class MP3
location: class Sound
Sound mp3 = new MP3(filename);
^
4 errors
Process completed.
Re: [RESOLVED] Sound not working
It's because javazoom is a library, not in the JDK, you need to download it and reference it in your classpath
Re: [RESOLVED] Sound not working
i got that by using google, i didnt test because i thought this would work.