Alexandru Circus
Alexandru Circus

Reputation: 5538

MediaPlayer throws IOException for wav file

I have an audio recording app on android, and I've encountered a strange issue on a friend's phone.

One of the recordings did not work and throws:

E/MediaPlayer-JNI(5996): QCMediaPlayer mediaplayer NOT present
E/MediaPlayer(5996): Unable to create media player
E/com.audioRec.player.MediaPlayer(5996): setDataSourceFD failed.: status=0x80000000
E/com.audioRec.player.MediaPlayer(5996): java.io.IOException: setDataSourceFD failed.: status=0x80000000

but it is playing with success on windows media player, vlc player, etc !!!!!!!!!

Could someone take a look over the header of the "RecordingNotOk.wav" file?

Here are both recordings

Upvotes: 0

Views: 927

Answers (1)

alextk
alextk

Reputation: 6239

For the RecordingNotOk.wav file, it sounds like the specified size of the data chunk is bigger than the file size: 00 F8 0A 00 in little endian is 718848 bytes while the whole file size is only 716844 and the actual data size available for this chunk is only 716800

This number can be found here (3rd line after 'data'):

52 49 46 46  24 F0 0A 00  57 41 56 45  66 6D 74 20  RIFF $ð?? WAVE fmt 
10 00 00 00  01 00 02 00  80 3E 00 00  00 FA 00 00  ???? ???? >?? ?ú??
04 00 10 00  64 61 74 61  00 F8 0A 00  00 00 00 00  ???? data ?ø?? ????

Basically it seems that your file has been truncated. Some players might ignore this and try to play whatever is available up to the end of the file. I guess on Android it tries to read the whole file first according to the expected size hence the IOException

Upvotes: 1

Related Questions