maxcatozzi

Somehow I got it to work like this:

try
        {
            input = new FileInputStream("01 You Know I Got the Time.wav");
            stream = new AudioStream(input);
            player.start(stream);

        }

maxcatozzi

When I use a wav file I'm getting this output instead "java.io.IOException: could not create AudioData object" - Maybe mp3 doesn't work. It seems to read in the file fine now, but has issues making the AudioData.

maxcatozzi

Thanks for the help.

When I use this as the catch:

catch(IOException error)
   {
       System.out.println(error);
       //System.out.println("fle not found");
   }

I end up getting: "java.io.IOException: could not create audio stream from input stream" as the output.
I've heard that using javax.sound.sampled is good for things like game sounds, because you have to use Clip class? But doesn't it have a few second limit? The issue is I have to play full songs. Any tips?

maxcatozzi

Hey, Does anyone see anything wrong with this? I don't know what's up, it's throwing the IOException everyt time even though the mp3 is in the source folder. (I tried .wav as well). I'm trying to place this in a GUI, but testing it seperately first.

import java.io.*;
import sun.audio.*;
import java.io.File;
import javax.swing.*;
import java.awt.event.*;
public class Test2 {

   public static void main(String[] args) {

AudioPlayer player = AudioPlayer.player;
   AudioStream stream;
   AudioData data;
   ContinuousAudioDataStream loop = null;
   InputStream input = null;

   try
   {
       input = new FileInputStream("GarageBand.mp3");
       stream = new AudioStream(input);
       data = stream.getData();
       loop = new ContinuousAudioDataStream(data);
       player.start(loop);

   }
   catch(IOException err)
   {
          System.out.println("fle not found");
   }

    }
}