tags:

views:

49

answers:

1

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.

A: 

Another issue may be that the file has been corrupted during download somehow... I recently had this exact same issue with images that I downloaded from a google images search... for some reason the files kept getting corrupted... I still haven't found a solution. I think that somehow the HTTP client is losing packets.

androidworkz
No,File is not corrupted, I played the file by copying it to the music folder. So I think, it is related to plying it with MediaPlayer thru code. Any help?
Raj
maybe have a look at http://code.google.com/p/ringdroid/
androidworkz