公开Java Midi Sequencer?

时间:2013-12-15 15:53:04

标签: java audio scope midi

我正在为我的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");
            }
}

0 个答案:

没有答案