I'm trying to get background music to play in a text adventure I am making. However, I cant get the sound class to work.
import sun.audio.*;
import java.io.*;
public class Sound {
public static void music()
{
AudioPlayer MGP = AudioPlayer.player;
AudioStream BGM;
AudioData MD;
ContinuousAudioDataStream loop = null;
try
{
InputStream test = new FileInputStream(new File "TrainerRedMusic.wav");
BGM = new AudioStream(test);
AudioPlayer.player.start(BGM);
}
catch(FileNotFoundException e){
System.out.print(e.toString());
}
catch(IOException error)
{
System.out.print(error.toString());
}
MGP.start(loop);
}
}
I have scoured the internet looking for a simple guide, but nothing works for what I am doing. I am just trying to run a .wav file in the background of my text adventure. Any help?