Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Cannot get Java to play a sound...

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cannot get Java to play a sound...

    Here is the code... What is wrong?

    public static void music() {
    		AudioPlayer MGP = AudioPlayer.player;
    		AudioStream BGM;
    		AudioData MD;
    		ContinuousAudioDataStream loop = null;
     
    		try {
    			BGM = new AudioStream(new FileInputStream("track.au"));
    			MD = BGM.getData();
    			loop = new ContinuousAudioDataStream(MD);
    		} catch(IOException error) {}
     
    		MGP.start(loop);
    	}

    Kind,
    Regards Jump


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,358
    Thanks
    182
    Thanked 834 Times in 777 Posts
    Blog Entries
    5

    Default Re: Cannot get Java to play a sound...

    That empty catch exception might be the place to start...are there exceptions thrown?

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot get Java to play a sound...

    Aaah, I solved it.
    Thanks for reminding me about the exception part :-)

    Kind,
    Regards Jump

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot get Java to play a sound...

    Hmm, now it's not working again O.O

    It says:
    java.io.IOException: could not create AudioData object
    at sun.audio.AudioStream.getData(Unknown Source)
    at aa.music(aa.java:48)
    at aa.main(aa.java:22)

    How can I solve this? The code looks exactly the same as when it worked

Similar Threads

  1. Will Play! Framework Java is he interested in?
    By laresistance2 in forum Web Frameworks
    Replies: 1
    Last Post: September 22nd, 2011, 02:26 PM
  2. Java sound API
    By bondage in forum Java SE APIs
    Replies: 3
    Last Post: July 22nd, 2010, 02:01 PM
  3. playing sound using java
    By sdhilipan89 in forum Java Applets
    Replies: 6
    Last Post: March 25th, 2010, 09:59 AM
  4. Java refuses to play sound on my machine
    By DDgeva in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: January 31st, 2010, 08:58 AM
  5. Replies: 2
    Last Post: January 8th, 2010, 08:22 AM