Results 1 to 8 of 8

Thread: [RESOLVED] Sound not working

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2008
    Posts
    54

    Resolved [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();
    		
    	}
    	
    	
    }

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2008
    Posts
    54

    Re: Sound not working

    ok Thank you very much for pointing me in the right direction

  4. #4
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: [RESOLVED] Sound not working


  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2008
    Posts
    54

    Re: [RESOLVED] Sound not working

    Justa Lol, thank you for the link the information was very clear and straight forward

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2008
    Posts
    54

    Re: [RESOLVED] Sound not working

    Quote 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.

  7. #7
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  8. #8
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    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
  •  



Click Here to Expand Forum to Full Width