我正在为我的java游戏创建一个静音按钮,而midi音序器拒绝从其子程序中访问,我该如何解决这个问题?
private void btnMuteMouseReleased(java.awt.event.MouseEvent evt) {
try{
if(IsPlaying == false){
InputStream midi = getClass().getResourceAsStream("sean"
+ "_kingston-fire_burning.mid");
Sequence sequence = MidiSystem.getSequence(midi);
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(sequence);
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
sequencer.start();
IsPlaying = true;
}else{
*ERROR* sequencer.stop(); *ERROR*
IsPlaying = false;
}
}catch(Exception e){
System.out.println("Failed to Load Midi and/or Sequencer");
}
}