FileDocCategorySizeDatePackage
AndroidMidiFileReader.javaAPI DocAndroid 1.5 API2691Wed May 06 22:41:02 BST 2009com.android.internal.sound.midi

AndroidMidiFileReader

public class AndroidMidiFileReader extends MidiFileReader
Implements a MidiFileReader for Android. We need to cache data coming from an arbitrary InputStream, since the Android MediaPlayer expects us to pass in a file or a URL.

Fields Summary
Constructors Summary
Methods Summary
public javax.sound.midi.MidiFileFormatgetMidiFileFormat(java.io.File file)

        throw new UnsupportedOperationException();
    
public javax.sound.midi.MidiFileFormatgetMidiFileFormat(java.io.InputStream stream)

        throw new UnsupportedOperationException();
    
public javax.sound.midi.MidiFileFormatgetMidiFileFormat(java.net.URL url)

        throw new UnsupportedOperationException();
    
public javax.sound.midi.SequencegetSequence(java.io.File file)

        return new AndroidSequence(file.toURL());
    
public javax.sound.midi.SequencegetSequence(java.io.InputStream stream)

        File file = File.createTempFile("javax.sound.midi-", null);
        file.deleteOnExit();

        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
        byte[] buffer = new byte[1024];

        int count = stream.read(buffer);
        while (count >= 0) {
            out.write(buffer, 0, count);
            count = stream.read(buffer);
        }

        out.flush();
        out.close();

        return getSequence(file);
    
public javax.sound.midi.SequencegetSequence(java.net.URL url)

        return new AndroidSequence(url);