views:

16

answers:

1

I could play MIDI file where "filename" is a String type with "asd.mid" value. However, I tried to sent AIR's nativeprocess command to Java, it shown "could not read" error. How come?

Java:

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);
        }
    }
A: 

Is one using a relative path and the other an absolute? Unless both applications are sitting in the same folder, I'd imagine you'd need the filepath rather than just the filename.

Gregor Kiddie
I suppose the MIDI do not accept absolute path? It only support URL, File and InputStream.
It'll be the File construction that's causing the IOExcpetion as it can't find the file specified, its what needs the absolute path... I'm guessing... as your exception handling has basically wiped out any useful info.
Gregor Kiddie