Hello,
I've been working on a new little game project and I could use some help. I've been trying to put background music into my game, but when I run this code
//Background music
try
{
Sequence sequence = MidiSystem.getSequence(new FileInputStream("bgm to try.mid"));
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(sequence);
sequencer.start();
}
catch(FileNotFoundException e)
{
System.out.println("Sound Problem1");
}
catch(MidiUnavailableException e)
{
System.out.println("Sound Problem2");
}
catch(InvalidMidiDataException e)
{
System.out.println("Sound Problem3");
}
catch(IOException e)
{
System.out.println("Sound Problem4");
}
in main, Sound Problem1 is printed out to standard output and the program works fine, but no sound is played. I’ve had a lot of trouble with file input streams in the past, and I didn’t have any file input code other than that, but I’m honestly not sure how to fix this code or other alternative to explore. The file name appears to be correct and it’s in my source folder in eclipse, so I’m not sure if that’s the problem. Can anyone here provide some advice? I would really appreciate any help.
Thanks!