I am trying to play a wave file(VoiceMail) in Android. The file is downloaded from a remote server and written to sdcard.
I use the following code to play the Wave file usign the MediaPlayer class bundled with the SDK:
FileDescriptor fd = new FileInputStream(songFile).getFD();
MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer.reset();
try{
mMediaPlayer.setDataSource(fd);
}
catch(IllegalStateException e){
mMediaPlayer.reset();
mMediaPlayer.setDataSource(fd);
}
mMediaPlayer.prepare();
mMediaPlayer.start();
However when I run my code, I get the following error: Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported error (1, -4).
Note that when I pull this file on my desktop machine and copy it to the Music folder of my HTC hero device, the Music player of the device can play this file so I am guessing the file format is compatible with Android.
Not sure of what the problem is; please help.
Thanks.