FileDocCategorySizeDatePackage
AndroidAudioFileReader.javaAPI DocAndroid 1.5 API2894Wed May 06 22:41:02 BST 2009com.android.internal.sound.sampled

AndroidAudioFileReader

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

Fields Summary
Constructors Summary
Methods Summary
public javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.io.File file)

        throw new UnsupportedOperationException();
    
public javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.io.InputStream stream)

        throw new UnsupportedOperationException();
    
public javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.net.URL url)

        throw new UnsupportedOperationException();
    
public javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.io.File file)

        return new AndroidAudioInputStream(file.toURL());
    
public javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.io.InputStream stream)

        File file = File.createTempFile("javax.sound.sampled-", 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 getAudioInputStream(file);
    
public javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.net.URL url)

        return new AndroidAudioInputStream(url);