0

So what I have tried to do is make my application play music in the background with a .wav music file.
I have this code but AudioStream can't be found under

sun.audio.*;

If any of you have worked with Eclipse IDE, how would you be able to find AudioStream to import it...

Here's my code which this uses. It's under the Sound class which doesn't implement or extend anything.

private AudioStream as;
private String lastSoundPath;

private void setStream(String soundPath){
    this.lastSoundPath = soundPath;
    try {
        InputStream in = new FileInputStream(soundPath);
        this.as = new AudioStream(in);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Here's the error I get when trying to play Bangarang (Random I know...)

java.io.IOException: could not create audio stream from input stream
at sun.audio.AudioStream.<init>(AudioStream.java:82)
at vapour.studios.destiny.client.Sound.setStream(Sound.java:17)
at vapour.studios.destiny.client.Sound.<init>(Sound.java:24)
at vapour.studios.destiny.Destiny.main(Destiny.java:23)

Thanks in advance.

KeirDavis
  • 665
  • 2
  • 10
  • 32

1 Answers1

0

You need to use javaSE 1.7 as execution environment in project properties.

it worked for me on Mac OS 10.8

Khaledvic
  • 534
  • 4
  • 16