plugmind
plugmind

Reputation: 7986

MediaPlayer.setDataSource fails on AMR audio file

01-15 00:57:08.660: WARN/System.err(25286): java.io.IOException: setDataSourceFD failed.: status=0x80000000
01-15 00:57:08.660: WARN/System.err(25286):     at android.media.MediaPlayer.setDataSource(Native Method)
01-15 00:57:08.660: WARN/System.err(25286):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:854)
...

...when trying to play local AMR audio file from application cache directory. It happens on HTC Magic, HTC Desire. AMR audio file is recorded by SonyEricsson xperia x10 mini and was downloaded from the Internet.

MediaPlayer is created in following way:

MediaPlayer player = new MediaPlayer();
player.setOnCompletionListener(this);
player.setOnErrorListener(this);
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
 FileInputStream fis = new FileInputStream(filePath);
 player.setDataSource(fis.getFD());
} catch (Exception e) {
 ...
}

Any ideas?

Upvotes: 4

Views: 2420

Answers (1)

marwatk
marwatk

Reputation: 130

I've noticed that certain setDataSource calls can fail on different devices (probably due to idiosyncrasies in the platform specific player). For example, what fails using setDataSource( FileDescriptor ) may work fine with setDataSource( Context, Uri ) or setDataSource( String ).

Try using one of the others and see if that works.

Upvotes: 1

Related Questions