I have an application that will record and play audio files. Some of the audio files are downloaded using simple standard http downloads using httpclient. It worked like a charm for a long time. Now all of a sudden I cannot play the files I download. It fails with this stack. I store the files on the SDCard and I experience the problem both on a handset and a USB connected device.

I have checked that the downloaded file is cool on the server, and I can play it without any issues.

These are the code snippets I use ( I know that recordingFile is a valid path for the file).

    // inside the activity class
    private void playRecording() throws IOException{
        File recordingFile = new File(recordingFileName);
        FileInputStream recordingInputStream = new FileInputStream(recordingFile); 
        audioMediaPlayer.playAudio(recordingInputStream);
    }

Here is the media player code:

    // inside my media player class which handles the recordings
    public void playAudio(FileInputStream audioInputStream) throws IOException {
        mediaPlayer.reset();
        mediaPlayer.setDataSource(audioInputStream.getFD());
        mediaPlayer.prepare();
        mediaPlayer.start();
}

Here is the exception:

E/MediaPlayerService(  555): offset error
E/MediaPlayer(  786): Unable to to create media player
W/System.err(  786): java.io.IOException: setDataSourceFD failed.: status=0x80000000
W/System.err(  786):    at android.media.MediaPlayer.setDataSource(Native Method)
W/System.err(  786):    at android.media.MediaPlayer.setDataSource(MediaPlayer.java:632)
W/System.err(  786):    at net.xxx.xxx.AudioMediaPlayer.playAudio(AudioMediaPlayer.java:69)
W/System.err(  786):    at net.xxx.xxx.Downloads.playRecording(Downloads.java:299)
W/System.err(  786):    at net.xxx.xxx.Downloads.access$0(Downloads.java:294)
W/System.err(  786):    at net.xxx.xxx.Downloads$1.onClick(Downloads.
Edit
Report