views:

13

answers:

0

I still confuse if I don't use command line to sent parameter through Flex application to Jar with "xyz.mid" as a filename, to the read input, it throw me an error which cannot read and when I use command line, it works! How do I get the Nativeprocess to work?

I found it could display exactly the right filename, it is not the location which should throw different exception. "Cannot read Midi" mean either the file cannot be load or is not in correct path?

http://stackoverflow.com/questions/4030547/unable-to-send-midi-file-name-to-java-to-playback-music

private void playMidi() {
 if(isPlaying.equals("0")) {
  try {
      song = MidiSystem.getSequence(new File(filename)); 
            sequencer = MidiSystem.getSequencer();
            sequencer.setSequence(song);
            sequencer.open();
            sequencer.addMetaEventListener(this);
            sequencer.start();
        } catch (InvalidMidiDataException e) {
            System.out.println("Bad midi file: "+ filename);
            //System.exit(1);
        } catch (MidiUnavailableException e) {System.out.println("No sequencer available");
            //System.exit(1);
        } catch (IOException e) {System.out.println("Could not read: "+ filename);
            //System.exit(1);
        }
        displayMidiInfo(filename);
  } else {
  updateTempoFactor(speed);
  }
 }