1

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?

Morvader
  • 2,317
  • 3
  • 31
  • 44
Igniro
  • 11
  • 3
  • I think this post might help you: http://stackoverflow.com/questions/13573281/how-to-play-a-background-music-when-the-program-run-in-java – Mandar Pandit Aug 07 '14 at 14:30

0 Answers0