I wrote a class to play a midi file. I've tested this class by running it in it's own thread, and it play's the intended song, but it also prints a warning in red:
May 21, 2014 12:55:03 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
My code works, but I'd like to know what this warning means and how to fix it.
public class MusicBox implements Runnable {
private Sequence midi;
private Sequencer sequencer;
private boolean playSong;
public MusicBox() {
try {
this.midi = MidiSystem.getSequence(new File("src//BennyHill.mid"));
this.sequencer = MidiSystem.getSequencer();
} catch (InvalidMidiDataException e) {
System.out.println("invalidMidiData exception in Music Box");
e.printStackTrace();
} catch (IOException e){
System.out.println("IO exception in Music Box");
e.printStackTrace();
} catch (MidiUnavailableException e) {
System.out.println("Midi Unavailable Exception in Music Box");
e.printStackTrace();
}
this.playSong = false;
}
@Override
public void run() {
try {
this.sequencer.open();
this.sequencer.setSequence(this.midi);
} catch (MidiUnavailableException e) {
System.out.println("MidiUnavailableException in play music (run)");
e.printStackTrace();
} catch (InvalidMidiDataException e) {
System.out.println("InvalidMidiDataException in play music (run)");
e.printStackTrace();
}
this.sequencer.start();
while(this.playSong){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
//do nothing
}
}
this.sequencer.stop();
this.sequencer.close();
}
}
User contributions licensed under CC BY-SA 3.0