|
-
Nov 8th, 2008, 06:32 PM
#1
Thread Starter
Member
[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:
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();
}
}
-
Nov 8th, 2008, 06:53 PM
#2
Re: Sound not working
I don't think you can play MP3 files using the JDK itself, I guess you'll need to use the JMF (Java Media Framework)
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Nov 8th, 2008, 08:25 PM
#3
Thread Starter
Member
Re: Sound not working
ok Thank you very much for pointing me in the right direction
-
Nov 19th, 2008, 01:58 PM
#4
Fanatic Member
Re: [RESOLVED] Sound not working
-
Nov 19th, 2008, 03:36 PM
#5
Thread Starter
Member
Re: [RESOLVED] Sound not working
Justa Lol, thank you for the link the information was very clear and straight forward
-
Nov 19th, 2008, 06:56 PM
#6
Thread Starter
Member
Re: [RESOLVED] Sound not working
 Originally Posted by Justa Lol
I followed the instructions but I got the following errors:
--------------------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.
-
Nov 19th, 2008, 07:07 PM
#7
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Nov 19th, 2008, 09:06 PM
#8
Fanatic Member
Re: [RESOLVED] Sound not working
i got that by using google, i didnt test because i thought this would work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|