I have problem with setDataSource(FileDescriptor) or setDataSource(FileDescriptor, offset, length).
The following works:
...
case LOCAL_AUDIO:
path = "/sdcard/sample.wav";
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path); // this works
mMediaPlayer.prepare();
mMediaPlayer.start();
...
If I use the following, a prepare() error and setDatasource() error throwed as IOException both on emulator 1.6 and 2.0:
....
// sample.wav has size about 400,000 bytes
File f = new File(android.os.Environment.getExternalStorageDirectory()+"/sample.wav");
FileInputStream fileIS = null;
FileDescriptor fd = null;
fileIS = new FileInputStream(f);
fd = fileIS.getFD(); // seems work as no "Filenotfound" exception throwed
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(fd, 1, 200000); // error
mMediaPlayer.prepare(); // error , prepareAsync() also doesn't work
mMediaPlayer.start();
....
I am new to android and is it wrong with the filestream / filedescriptor?
Thanks in advance for any help!


